[ 
https://issues.apache.org/jira/browse/THRIFT-2064?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14102127#comment-14102127
 ] 

Randy Abernethy commented on THRIFT-2064:
-----------------------------------------

Hey Sherban,

I do not think the assumption here is correct. Node transport write() methods 
only accept Buffers (or strings which are immediately turned into buffers). 
These buffers are added to the outBuffers array. There should _never_ be 
anything in the outBuffers array other than Buffers, making copy an acceptable 
call. Protocols like TBinaryProtocol and TJSONProtocol, all convert the Thrift 
supported primitives to buffers before calling trans.write(). For example 
TJSONProtocol writeBool() adds a 1 or 0 to an internal tstack array which is 
then converted to a buffer in writeMessageEnd() prior to being written to the 
transport with trans.write().

This makes me believe that there is something else causing your problem. One 
concern is that anything other than the node.js version in the trunk should be 
considered strongly suspect. If you are using the node lib from 0.9.1 I would 
definitely switch to the trunk. Many (and I mean many) problems have been 
repaired in what will shortly be 0.9.2. 

If you can submit a complete but minimal example of the code that fails I'd be 
happy to look it over. You also might want to take a look at the tests, there 
are several examples  in nodejs/test/thrift_test_driver.js where primitives are 
used as map values and all pass for me with all of the protocols and transport 
combinations..

I'm going to close this issue for now, feel free to reopen if you have a test 
case that fails or other concerns.

Best,
Randy

> Node thrift can't handle maps with primitive values
> ---------------------------------------------------
>
>                 Key: THRIFT-2064
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2064
>             Project: Thrift
>          Issue Type: Bug
>          Components: Node.js - Library
>    Affects Versions: 0.9
>            Reporter: Sherban Drulea
>            Priority: Critical
>              Labels: node, nodejs
>             Fix For: 0.9.2
>
>
> When passing a map with primitive values (i.e. boolean or integer) via the 
> thrift-npm, I get the following error:
> ERROR:Object false has no method 'copy'
> The error is from the many copy() calls in thrift-npm: 
> thrift/lib/thrift/transport.js
> transport.js calls copy() on primitive thrift function parameters (i.e. int 
> and boolean).
> Example IDL:
> struct SetTeamPrivilegesParams {
>   1: optional i32 teamId,
>   2: optional string platform,
>   3: optional string title,
>   4: optional map<string,bool> privileges
> }
> /**
>   * Sets the bit offsets in the Key Archive index for the various privileges 
> sent by the client. 
>   **/
>   SetTeamPrivilegesResponse setTeamPrivileges(1: SetTeamPrivilegesParams 
> params) throws (1: ServiceException ex)
> Example Client Code (vars in 'values' are all boolean):
> var updateTeamParams = new ttypes.UpdateTeamParams({
>         teamId: teamId,
>         platform: platform,
>         title: title,
>         values: {   'canEditEmblem': false,
>                     'isBanned': true
>                 }
>     });
>     var argsArray = [updateTeamParams];
>     try{
>         tc.call( 'setTeamPrivileges', argsArray, restResponse );
>     }
>     catch(err){ console.log( "ERROR:" + err.message ) };
> ERROR:Object false has no method 'copy'
> Please fix transports.js to handle map parameters with primitives. 



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to