You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by C Bergström <cb...@pathscale.com> on 2019/03/11 09:32:11 UTC

Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Hi

I'm really super stuck and kindly ask for some help. I'm working on a
python based client, but seeing some correct or spurious extra comma and
wondering what on earth am I doing wrong.

For example
[1,"auth",1,0,
vs
[1"auth"10

I swear my code is correct?!! (The C# version does work.. I tried reading
the source, but it looked fine and it does work at the end of the day.)

// I test with thrift compiler 12 and 13 git head
auth_args.thrift
-------------
namespace py auth_args

struct Data {
    1: required i32 project_id
    2: required i64 uid
    3: required string auth_token
    4: required string version
    5: map<string,string> kv
}

exception RtmGatedException {
    1: i32 code
    2: string reason
}


service AuthArgs {
    bool auth(1:i32 project_id 2:i64 uid 3:string auth_token 4:string
version 5:map<string, string> kv)
}
----------------

Swapped to JSON protocol just so I could get something readable
Python New
// Many extra comma and the end has a lot of extra parentheses
load      =
'[1,"auth",1,0,{"1":{"rec":{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str","str",0,{}]}}}}]'


C# example output just for testing
          =
[1"auth"10{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str""str"0{}}]

Binary portocol for anyone with a batman decoder ring (I couldn't get the
c++ debug tool to build :-/ )

I'm kinda concerned the magic bit is different.. How would I even change
this in Python?
----------------
Python New
\x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\x89\x05\x8a\x0b\x00\x03\x00\x00\x00
ED237CF629A6CD7AF601659A39CECFDC\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00

C# old working
\x00\x00\x00\x82\x0f\xff\x00\x01\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\xf7e#\x0b\x00\x03\x00\x00\x00
6E97028A8240EC2B8BB1C6C8932A6E60\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00

Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by C Bergström <cb...@pathscale.com>.
On Tue, Mar 12, 2019 at 8:45 AM Jens Geyer <je...@hotmail.com> wrote:

> Hi,
>
> > I think the comma issue doesn't impact me since we are using binary
> > protocol and the json protocol was just for human readability.
>
> Agree, but thanks anyway for spotting it.
>
> > By "not working" I mean when I try to login to the server it fails. All
> my
> > field values are correct, but I can only assume the server doesn't parse
> > things the same and fails.
>
> Any error messages maybe? Why do we have to always ask?
>

Server returns a bool - Success / Fail as in my original auth_args.thrift
you can see.


> > Is there a way for me to turn off this implicit rec and test?
>
> No, and you should not even try. It is part of the way how Thrift works.
>

Ok. then unless someone can look at the binary protocol stuff to see what's
different I feel very stuck. All the fields should be passing similar values

Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by Jens Geyer <je...@hotmail.com>.
Hi,

> I think the comma issue doesn't impact me since we are using binary
> protocol and the json protocol was just for human readability.

Agree, but thanks anyway for spotting it.

> By "not working" I mean when I try to login to the server it fails. All my
> field values are correct, but I can only assume the server doesn't parse
> things the same and fails.

Any error messages maybe? Why do we have to always ask?

> Is there a way for me to turn off this implicit rec and test?

No, and you should not even try. It is part of the way how Thrift works.



-----Ursprüngliche Nachricht----- 
From: C Bergström
Sent: Tuesday, March 12, 2019 1:30 AM
To: user@thrift.apache.org
Subject: Re: Python client vs C# client json/binary different.. a lot of 
extra comma!! (confused)

On Tue, Mar 12, 2019 at 7:58 AM Jens Geyer <je...@hotmail.com> wrote:

> > ok so maybe I should be asking where is the extra "1":{"rec": coming
> from.
> > Based on my auth_args.thrift I don't see why it should be generated.
>
> That is all fine. request and responses are implicitly wrapped into a
> struct, that's where the "rec" comes from. It's not in the IDL, it is
> added
> implicitly by Thrift and yes, we need that.
>
> Why py does "not work" (still not clear what it means) - no idea. But the
> JSON that comes out of C#/netcore/netstd is certainly wrong. I just
> stepped
> through the code and the commas seem indeed missing, if I did not overlook
> anything.
>

I think the comma issue doesn't impact me since we are using binary
protocol and the json protocol was just for human readability.

By "not working" I mean when I try to login to the server it fails. All my
field values are correct, but I can only assume the server doesn't parse
things the same and fails.

Is there a way for me to turn off this implicit rec and test?

What tool can I used to decode the binary protocol version so I can look
for differences there. 


Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by C Bergström <cb...@pathscale.com>.
On Tue, Mar 12, 2019 at 7:58 AM Jens Geyer <je...@hotmail.com> wrote:

> > ok so maybe I should be asking where is the extra "1":{"rec": coming
> from.
> > Based on my auth_args.thrift I don't see why it should be generated.
>
> That is all fine. request and responses are implicitly wrapped into a
> struct, that's where the "rec" comes from. It's not in the IDL, it is
> added
> implicitly by Thrift and yes, we need that.
>
> Why py does "not work" (still not clear what it means) - no idea. But the
> JSON that comes out of C#/netcore/netstd is certainly wrong. I just
> stepped
> through the code and the commas seem indeed missing, if I did not overlook
> anything.
>

I think the comma issue doesn't impact me since we are using binary
protocol and the json protocol was just for human readability.

By "not working" I mean when I try to login to the server it fails. All my
field values are correct, but I can only assume the server doesn't parse
things the same and fails.

Is there a way for me to turn off this implicit rec and test?

What tool can I used to decode the binary protocol version so I can look
for differences there.

Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by Jens Geyer <je...@hotmail.com>.
> ok so maybe I should be asking where is the extra "1":{"rec": coming from.
> Based on my auth_args.thrift I don't see why it should be generated.

That is all fine. request and responses are implicitly wrapped into a 
struct, that's where the "rec" comes from. It's not in the IDL, it is added 
implicitly by Thrift and yes, we need that.

Why py does "not work" (still not clear what it means) - no idea. But the 
JSON that comes out of C#/netcore/netstd is certainly wrong. I just stepped 
through the code and the commas seem indeed missing, if I did not overlook 
anything.

https://issues.apache.org/jira/browse/THRIFT-4816




-----Ursprüngliche Nachricht----- 
From: C Bergström

ok so maybe I should be asking where is the extra "1":{"rec": coming from.
Based on my auth_args.thrift I don't see why it should be generated.

On Tue, Mar 12, 2019 at 7:22 AM C Bergström <cb...@pathscale.com>
wrote:

>
>
> On Tue, Mar 12, 2019 at 7:20 AM Jens Geyer <je...@hotmail.com> wrote:
>
>> Ah, that one:
>>
>> >  [1"auth"10
>>
>
> I know!, but I swapped the binary protocol emitter for json emitter in the
> C# client and that's what I got. Using the binary protocol it works..
>
> I included the binary versions in case someone can decode those. I'm at a
> total loss of why the C# version works and python doesn't.
> 


Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by C Bergström <cb...@pathscale.com>.
ok so maybe I should be asking where is the extra "1":{"rec": coming from.
Based on my auth_args.thrift I don't see why it should be generated.

On Tue, Mar 12, 2019 at 7:22 AM C Bergström <cb...@pathscale.com>
wrote:

>
>
> On Tue, Mar 12, 2019 at 7:20 AM Jens Geyer <je...@hotmail.com> wrote:
>
>> Ah, that one:
>>
>> >  [1"auth"10
>>
>
> I know!, but I swapped the binary protocol emitter for json emitter in the
> C# client and that's what I got. Using the binary protocol it works..
>
> I included the binary versions in case someone can decode those. I'm at a
> total loss of why the C# version works and python doesn't.
>

Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by C Bergström <cb...@pathscale.com>.
On Tue, Mar 12, 2019 at 7:20 AM Jens Geyer <je...@hotmail.com> wrote:

> Ah, that one:
>
> >  [1"auth"10
>

I know!, but I swapped the binary protocol emitter for json emitter in the
C# client and that's what I got. Using the binary protocol it works..

I included the binary versions in case someone can decode those. I'm at a
total loss of why the C# version works and python doesn't.

Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by Jens Geyer <je...@hotmail.com>.
Ah, that one:

>  [1"auth"10

That is not valid JSON.

http://json.org



-----Ursprüngliche Nachricht----- 
From: Jens Geyer
Sent: Tuesday, March 12, 2019 12:18 AM
To: user@thrift.apache.org
Subject: Re: Python client vs C# client json/binary different.. a lot of 
extra comma!! (confused)

What extra comma?

-----Ursprüngliche Nachricht----- 
From: C Bergström
Sent: Tuesday, March 12, 2019 12:04 AM
To: user@thrift.apache.org
Subject: Re: Python client vs C# client json/binary different.. a lot of
extra comma!! (confused)

But do you think that's the issue or the extra comma? I'm not sure I see
the bug

On Tue, Mar 12, 2019 at 6:51 AM Jens Geyer <je...@hotmail.com> wrote:

> FWIW, the JSON structure totally makes sense:
>
> [
>   1,
>   "auth",
>   1,
>   0,
>   {
>     "1": {
>       "rec": {
>         "1": {
>           "i32": 40002
>         },
>         "2": {
>           "i64": 59311498
>         },
>         "3": {
>           "str": "MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"
>         },
>         "4": {
>           "str": "YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"
>         },
>         "5": {
>           "map": [
>             "str",
>             "str",
>             0,
>             {}
>           ]
>         }
>       }
>     }
>   }
> ]
>
>
> https://jsoneditoronline.org is quite helpful to find out where these
> parentheses may come from :-)
>
>
>
> -----Ursprüngliche Nachricht-----
> From: C Bergström
> Sent: Monday, March 11, 2019 10:32 AM
> To: user@thrift.apache.org
> Subject: Python client vs C# client json/binary different.. a lot of extra
> comma!! (confused)
>
> Hi
>
> I'm really super stuck and kindly ask for some help. I'm working on a
> python based client, but seeing some correct or spurious extra comma and
> wondering what on earth am I doing wrong.
>
> For example
> [1,"auth",1,0,
> vs
> [1"auth"10
>
> I swear my code is correct?!! (The C# version does work.. I tried reading
> the source, but it looked fine and it does work at the end of the day.)
>
> // I test with thrift compiler 12 and 13 git head
> auth_args.thrift
> -------------
> namespace py auth_args
>
> struct Data {
>     1: required i32 project_id
>     2: required i64 uid
>     3: required string auth_token
>     4: required string version
>     5: map<string,string> kv
> }
>
> exception RtmGatedException {
>     1: i32 code
>     2: string reason
> }
>
>
> service AuthArgs {
>     bool auth(1:i32 project_id 2:i64 uid 3:string auth_token 4:string
> version 5:map<string, string> kv)
> }
> ----------------
>
> Swapped to JSON protocol just so I could get something readable
> Python New
> // Many extra comma and the end has a lot of extra parentheses
> load      =
>
> '[1,"auth",1,0,{"1":{"rec":{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str","str",0,{}]}}}}]'
>
>
> C# example output just for testing
>           =
>
> [1"auth"10{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str""str"0{}}]
>
> Binary portocol for anyone with a batman decoder ring (I couldn't get the
> c++ debug tool to build :-/ )
>
> I'm kinda concerned the magic bit is different.. How would I even change
> this in Python?
> ----------------
> Python New
>
> \x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\x89\x05\x8a\x0b\x00\x03\x00\x00\x00
> ED237CF629A6CD7AF601659A39CECFDC\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
> beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00
>
> C# old working
>
> \x00\x00\x00\x82\x0f\xff\x00\x01\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\xf7e#\x0b\x00\x03\x00\x00\x00
> 6E97028A8240EC2B8BB1C6C8932A6E60\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
> beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00
>
>


Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by Jens Geyer <je...@hotmail.com>.
Hi,

> [1"auth"10
> "5":{"map":["str""str"0{}

If that's what C# is producing then it is very likely wrong. Worth a ticket, 
I'd say.

To answer the second part of the question, we need the full question: What 
does "not working" mean exactly?

Have fun,
JensG



-----Ursprüngliche Nachricht----- 
From: C Bergström
Sent: Tuesday, March 12, 2019 12:21 AM
To: user@thrift.apache.org
Subject: Re: Python client vs C# client json/binary different.. a lot of 
extra comma!! (confused)

It was near the 1st lines of my email
------------
For example
[1,"auth",1,0,
vs
[1"auth"10

"5":{"map":["str","str",0,{}
vs
"5":{"map":["str""str"0{}
The ones missing the comma works and it doesn't make any sense to me


On Tue, Mar 12, 2019 at 7:18 AM Jens Geyer <je...@hotmail.com> wrote:

> What extra comma?
>
> -----Ursprüngliche Nachricht-----
> From: C Bergström
> Sent: Tuesday, March 12, 2019 12:04 AM
> To: user@thrift.apache.org
> Subject: Re: Python client vs C# client json/binary different.. a lot of
> extra comma!! (confused)
>
> But do you think that's the issue or the extra comma? I'm not sure I see
> the bug
>
> On Tue, Mar 12, 2019 at 6:51 AM Jens Geyer <je...@hotmail.com> wrote:
>
> > FWIW, the JSON structure totally makes sense:
> >
> > [
> >   1,
> >   "auth",
> >   1,
> >   0,
> >   {
> >     "1": {
> >       "rec": {
> >         "1": {
> >           "i32": 40002
> >         },
> >         "2": {
> >           "i64": 59311498
> >         },
> >         "3": {
> >           "str": "MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"
> >         },
> >         "4": {
> >           "str": "YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"
> >         },
> >         "5": {
> >           "map": [
> >             "str",
> >             "str",
> >             0,
> >             {}
> >           ]
> >         }
> >       }
> >     }
> >   }
> > ]
> >
> >
> > https://jsoneditoronline.org is quite helpful to find out where these
> > parentheses may come from :-)
> >
> >
> >
> > -----Ursprüngliche Nachricht-----
> > From: C Bergström
> > Sent: Monday, March 11, 2019 10:32 AM
> > To: user@thrift.apache.org
> > Subject: Python client vs C# client json/binary different.. a lot of
> extra
> > comma!! (confused)
> >
> > Hi
> >
> > I'm really super stuck and kindly ask for some help. I'm working on a
> > python based client, but seeing some correct or spurious extra comma and
> > wondering what on earth am I doing wrong.
> >
> > For example
> > [1,"auth",1,0,
> > vs
> > [1"auth"10
> >
> > I swear my code is correct?!! (The C# version does work.. I tried 
> > reading
> > the source, but it looked fine and it does work at the end of the day.)
> >
> > // I test with thrift compiler 12 and 13 git head
> > auth_args.thrift
> > -------------
> > namespace py auth_args
> >
> > struct Data {
> >     1: required i32 project_id
> >     2: required i64 uid
> >     3: required string auth_token
> >     4: required string version
> >     5: map<string,string> kv
> > }
> >
> > exception RtmGatedException {
> >     1: i32 code
> >     2: string reason
> > }
> >
> >
> > service AuthArgs {
> >     bool auth(1:i32 project_id 2:i64 uid 3:string auth_token 4:string
> > version 5:map<string, string> kv)
> > }
> > ----------------
> >
> > Swapped to JSON protocol just so I could get something readable
> > Python New
> > // Many extra comma and the end has a lot of extra parentheses
> > load      =
> >
> >
> '[1,"auth",1,0,{"1":{"rec":{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str","str",0,{}]}}}}]'
> >
> >
> > C# example output just for testing
> >           =
> >
> >
> [1"auth"10{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str""str"0{}}]
> >
> > Binary portocol for anyone with a batman decoder ring (I couldn't get 
> > the
> > c++ debug tool to build :-/ )
> >
> > I'm kinda concerned the magic bit is different.. How would I even change
> > this in Python?
> > ----------------
> > Python New
> >
> >
> \x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\x89\x05\x8a\x0b\x00\x03\x00\x00\x00
> > ED237CF629A6CD7AF601659A39CECFDC\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
> > beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00
> >
> > C# old working
> >
> >
> \x00\x00\x00\x82\x0f\xff\x00\x01\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\xf7e#\x0b\x00\x03\x00\x00\x00
> > 6E97028A8240EC2B8BB1C6C8932A6E60\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
> > beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00
> >
> >
>
> 


Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by C Bergström <cb...@pathscale.com>.
It was near the 1st lines of my email
------------
For example
[1,"auth",1,0,
vs
[1"auth"10

"5":{"map":["str","str",0,{}
vs
"5":{"map":["str""str"0{}

The ones missing the comma works and it doesn't make any sense to me


On Tue, Mar 12, 2019 at 7:18 AM Jens Geyer <je...@hotmail.com> wrote:

> What extra comma?
>
> -----Ursprüngliche Nachricht-----
> From: C Bergström
> Sent: Tuesday, March 12, 2019 12:04 AM
> To: user@thrift.apache.org
> Subject: Re: Python client vs C# client json/binary different.. a lot of
> extra comma!! (confused)
>
> But do you think that's the issue or the extra comma? I'm not sure I see
> the bug
>
> On Tue, Mar 12, 2019 at 6:51 AM Jens Geyer <je...@hotmail.com> wrote:
>
> > FWIW, the JSON structure totally makes sense:
> >
> > [
> >   1,
> >   "auth",
> >   1,
> >   0,
> >   {
> >     "1": {
> >       "rec": {
> >         "1": {
> >           "i32": 40002
> >         },
> >         "2": {
> >           "i64": 59311498
> >         },
> >         "3": {
> >           "str": "MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"
> >         },
> >         "4": {
> >           "str": "YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"
> >         },
> >         "5": {
> >           "map": [
> >             "str",
> >             "str",
> >             0,
> >             {}
> >           ]
> >         }
> >       }
> >     }
> >   }
> > ]
> >
> >
> > https://jsoneditoronline.org is quite helpful to find out where these
> > parentheses may come from :-)
> >
> >
> >
> > -----Ursprüngliche Nachricht-----
> > From: C Bergström
> > Sent: Monday, March 11, 2019 10:32 AM
> > To: user@thrift.apache.org
> > Subject: Python client vs C# client json/binary different.. a lot of
> extra
> > comma!! (confused)
> >
> > Hi
> >
> > I'm really super stuck and kindly ask for some help. I'm working on a
> > python based client, but seeing some correct or spurious extra comma and
> > wondering what on earth am I doing wrong.
> >
> > For example
> > [1,"auth",1,0,
> > vs
> > [1"auth"10
> >
> > I swear my code is correct?!! (The C# version does work.. I tried reading
> > the source, but it looked fine and it does work at the end of the day.)
> >
> > // I test with thrift compiler 12 and 13 git head
> > auth_args.thrift
> > -------------
> > namespace py auth_args
> >
> > struct Data {
> >     1: required i32 project_id
> >     2: required i64 uid
> >     3: required string auth_token
> >     4: required string version
> >     5: map<string,string> kv
> > }
> >
> > exception RtmGatedException {
> >     1: i32 code
> >     2: string reason
> > }
> >
> >
> > service AuthArgs {
> >     bool auth(1:i32 project_id 2:i64 uid 3:string auth_token 4:string
> > version 5:map<string, string> kv)
> > }
> > ----------------
> >
> > Swapped to JSON protocol just so I could get something readable
> > Python New
> > // Many extra comma and the end has a lot of extra parentheses
> > load      =
> >
> >
> '[1,"auth",1,0,{"1":{"rec":{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str","str",0,{}]}}}}]'
> >
> >
> > C# example output just for testing
> >           =
> >
> >
> [1"auth"10{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str""str"0{}}]
> >
> > Binary portocol for anyone with a batman decoder ring (I couldn't get the
> > c++ debug tool to build :-/ )
> >
> > I'm kinda concerned the magic bit is different.. How would I even change
> > this in Python?
> > ----------------
> > Python New
> >
> >
> \x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\x89\x05\x8a\x0b\x00\x03\x00\x00\x00
> > ED237CF629A6CD7AF601659A39CECFDC\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
> > beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00
> >
> > C# old working
> >
> >
> \x00\x00\x00\x82\x0f\xff\x00\x01\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\xf7e#\x0b\x00\x03\x00\x00\x00
> > 6E97028A8240EC2B8BB1C6C8932A6E60\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
> > beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00
> >
> >
>
>

Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by Jens Geyer <je...@hotmail.com>.
What extra comma?

-----Ursprüngliche Nachricht----- 
From: C Bergström
Sent: Tuesday, March 12, 2019 12:04 AM
To: user@thrift.apache.org
Subject: Re: Python client vs C# client json/binary different.. a lot of 
extra comma!! (confused)

But do you think that's the issue or the extra comma? I'm not sure I see
the bug

On Tue, Mar 12, 2019 at 6:51 AM Jens Geyer <je...@hotmail.com> wrote:

> FWIW, the JSON structure totally makes sense:
>
> [
>   1,
>   "auth",
>   1,
>   0,
>   {
>     "1": {
>       "rec": {
>         "1": {
>           "i32": 40002
>         },
>         "2": {
>           "i64": 59311498
>         },
>         "3": {
>           "str": "MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"
>         },
>         "4": {
>           "str": "YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"
>         },
>         "5": {
>           "map": [
>             "str",
>             "str",
>             0,
>             {}
>           ]
>         }
>       }
>     }
>   }
> ]
>
>
> https://jsoneditoronline.org is quite helpful to find out where these
> parentheses may come from :-)
>
>
>
> -----Ursprüngliche Nachricht-----
> From: C Bergström
> Sent: Monday, March 11, 2019 10:32 AM
> To: user@thrift.apache.org
> Subject: Python client vs C# client json/binary different.. a lot of extra
> comma!! (confused)
>
> Hi
>
> I'm really super stuck and kindly ask for some help. I'm working on a
> python based client, but seeing some correct or spurious extra comma and
> wondering what on earth am I doing wrong.
>
> For example
> [1,"auth",1,0,
> vs
> [1"auth"10
>
> I swear my code is correct?!! (The C# version does work.. I tried reading
> the source, but it looked fine and it does work at the end of the day.)
>
> // I test with thrift compiler 12 and 13 git head
> auth_args.thrift
> -------------
> namespace py auth_args
>
> struct Data {
>     1: required i32 project_id
>     2: required i64 uid
>     3: required string auth_token
>     4: required string version
>     5: map<string,string> kv
> }
>
> exception RtmGatedException {
>     1: i32 code
>     2: string reason
> }
>
>
> service AuthArgs {
>     bool auth(1:i32 project_id 2:i64 uid 3:string auth_token 4:string
> version 5:map<string, string> kv)
> }
> ----------------
>
> Swapped to JSON protocol just so I could get something readable
> Python New
> // Many extra comma and the end has a lot of extra parentheses
> load      =
>
> '[1,"auth",1,0,{"1":{"rec":{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str","str",0,{}]}}}}]'
>
>
> C# example output just for testing
>           =
>
> [1"auth"10{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str""str"0{}}]
>
> Binary portocol for anyone with a batman decoder ring (I couldn't get the
> c++ debug tool to build :-/ )
>
> I'm kinda concerned the magic bit is different.. How would I even change
> this in Python?
> ----------------
> Python New
>
> \x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\x89\x05\x8a\x0b\x00\x03\x00\x00\x00
> ED237CF629A6CD7AF601659A39CECFDC\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
> beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00
>
> C# old working
>
> \x00\x00\x00\x82\x0f\xff\x00\x01\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\xf7e#\x0b\x00\x03\x00\x00\x00
> 6E97028A8240EC2B8BB1C6C8932A6E60\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
> beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00
>
> 


Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by C Bergström <cb...@pathscale.com>.
But do you think that's the issue or the extra comma? I'm not sure I see
the bug

On Tue, Mar 12, 2019 at 6:51 AM Jens Geyer <je...@hotmail.com> wrote:

> FWIW, the JSON structure totally makes sense:
>
> [
>   1,
>   "auth",
>   1,
>   0,
>   {
>     "1": {
>       "rec": {
>         "1": {
>           "i32": 40002
>         },
>         "2": {
>           "i64": 59311498
>         },
>         "3": {
>           "str": "MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"
>         },
>         "4": {
>           "str": "YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"
>         },
>         "5": {
>           "map": [
>             "str",
>             "str",
>             0,
>             {}
>           ]
>         }
>       }
>     }
>   }
> ]
>
>
> https://jsoneditoronline.org is quite helpful to find out where these
> parentheses may come from :-)
>
>
>
> -----Ursprüngliche Nachricht-----
> From: C Bergström
> Sent: Monday, March 11, 2019 10:32 AM
> To: user@thrift.apache.org
> Subject: Python client vs C# client json/binary different.. a lot of extra
> comma!! (confused)
>
> Hi
>
> I'm really super stuck and kindly ask for some help. I'm working on a
> python based client, but seeing some correct or spurious extra comma and
> wondering what on earth am I doing wrong.
>
> For example
> [1,"auth",1,0,
> vs
> [1"auth"10
>
> I swear my code is correct?!! (The C# version does work.. I tried reading
> the source, but it looked fine and it does work at the end of the day.)
>
> // I test with thrift compiler 12 and 13 git head
> auth_args.thrift
> -------------
> namespace py auth_args
>
> struct Data {
>     1: required i32 project_id
>     2: required i64 uid
>     3: required string auth_token
>     4: required string version
>     5: map<string,string> kv
> }
>
> exception RtmGatedException {
>     1: i32 code
>     2: string reason
> }
>
>
> service AuthArgs {
>     bool auth(1:i32 project_id 2:i64 uid 3:string auth_token 4:string
> version 5:map<string, string> kv)
> }
> ----------------
>
> Swapped to JSON protocol just so I could get something readable
> Python New
> // Many extra comma and the end has a lot of extra parentheses
> load      =
>
> '[1,"auth",1,0,{"1":{"rec":{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str","str",0,{}]}}}}]'
>
>
> C# example output just for testing
>           =
>
> [1"auth"10{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str""str"0{}}]
>
> Binary portocol for anyone with a batman decoder ring (I couldn't get the
> c++ debug tool to build :-/ )
>
> I'm kinda concerned the magic bit is different.. How would I even change
> this in Python?
> ----------------
> Python New
>
> \x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\x89\x05\x8a\x0b\x00\x03\x00\x00\x00
> ED237CF629A6CD7AF601659A39CECFDC\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
> beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00
>
> C# old working
>
> \x00\x00\x00\x82\x0f\xff\x00\x01\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\xf7e#\x0b\x00\x03\x00\x00\x00
> 6E97028A8240EC2B8BB1C6C8932A6E60\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
> beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00
>
>

Re: Python client vs C# client json/binary different.. a lot of extra comma!! (confused)

Posted by Jens Geyer <je...@hotmail.com>.
FWIW, the JSON structure totally makes sense:

[
  1,
  "auth",
  1,
  0,
  {
    "1": {
      "rec": {
        "1": {
          "i32": 40002
        },
        "2": {
          "i64": 59311498
        },
        "3": {
          "str": "MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"
        },
        "4": {
          "str": "YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"
        },
        "5": {
          "map": [
            "str",
            "str",
            0,
            {}
          ]
        }
      }
    }
  }
]


https://jsoneditoronline.org is quite helpful to find out where these 
parentheses may come from :-)



-----Ursprüngliche Nachricht----- 
From: C Bergström
Sent: Monday, March 11, 2019 10:32 AM
To: user@thrift.apache.org
Subject: Python client vs C# client json/binary different.. a lot of extra 
comma!! (confused)

Hi

I'm really super stuck and kindly ask for some help. I'm working on a
python based client, but seeing some correct or spurious extra comma and
wondering what on earth am I doing wrong.

For example
[1,"auth",1,0,
vs
[1"auth"10

I swear my code is correct?!! (The C# version does work.. I tried reading
the source, but it looked fine and it does work at the end of the day.)

// I test with thrift compiler 12 and 13 git head
auth_args.thrift
-------------
namespace py auth_args

struct Data {
    1: required i32 project_id
    2: required i64 uid
    3: required string auth_token
    4: required string version
    5: map<string,string> kv
}

exception RtmGatedException {
    1: i32 code
    2: string reason
}


service AuthArgs {
    bool auth(1:i32 project_id 2:i64 uid 3:string auth_token 4:string
version 5:map<string, string> kv)
}
----------------

Swapped to JSON protocol just so I could get something readable
Python New
// Many extra comma and the end has a lot of extra parentheses
load      =
'[1,"auth",1,0,{"1":{"rec":{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str","str",0,{}]}}}}]'


C# example output just for testing
          =
[1"auth"10{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str""str"0{}}]

Binary portocol for anyone with a batman decoder ring (I couldn't get the
c++ debug tool to build :-/ )

I'm kinda concerned the magic bit is different.. How would I even change
this in Python?
----------------
Python New
\x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\x89\x05\x8a\x0b\x00\x03\x00\x00\x00
ED237CF629A6CD7AF601659A39CECFDC\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00

C# old working
\x00\x00\x00\x82\x0f\xff\x00\x01\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\xf7e#\x0b\x00\x03\x00\x00\x00
6E97028A8240EC2B8BB1C6C8932A6E60\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0
beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00