Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4815

Golang thrift and Python don't write the same messages



    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Not A Bug
    • Affects Version/s: 0.11.0, 0.12.0
    • Fix Version/s: None
    • Labels:
    • Environment:


      I'm trying to port a tool that relies on Thrift from Python to Golang, it is a client not a server.

      The thrift protocol behaves inconsistent when comparing Python and Golang and it results in breaking applications.
      What it boils down to is I have a struct called Message with a certain amount of fields and I have a sendMessage method that takes that message and sends it to a server which then processes that.
      In Python I can simply make a Message object, set some user's userId as receiver and the text after which I can send the message using sendMessage()
      In Golang I can do the exact same but I run into error responses from the server saying another field that isn't required cannot be found.

      In Python this is the generated POST body sent to the server:

      In Golang the generated POST body sent to the server:

      As demonstrated above therre are two differences in the generated POST bodies but the one causing the error is the fact that the fields are in a different order than they are supposed to.

      In Golang trying to reverse the order of the fields causes this POST body to be generated:
      When commenting out all the fields I actually don't want to be written and then only reversing the functions that are actually writing data, the ones for the receiver and text fields the POST body looks like this:

      To summarize, the Thrift protocol on Golang is broken in certain cases because fields are not written in the right order causing other implementatings of Thrift to stop serving Golang Thrift clients.


        1. bunny.thrift
          1 kB
          Jack Flecher

          Issue Links



              • Assignee:
                jking3 James E. King III
                tmjbunny Jack Flecher
              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created: