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

Sherban Drulea edited comment on THRIFT-2064 at 7/17/13 4:23 AM:
-----------------------------------------------------------------

The problem code in flush() function of transport.js:
--------------------------------------------------------
flush: function() {
    var out = new Buffer(this.outCount),
        pos = 0;
    this.outBuffers.forEach(function(buf) {
      buf.copy(out, pos, 0); <!------------------- DOESN'T WORK FOR PRIMITIVES!
      pos += buf.length;
    });

copy() on line 119 is called on a primitive (false from the example code above).

Here's the stack trace of line 119 buf sent to copy() from the example code:

setTeamPrivileges (function name)
xbox (platform)
ops2 (title_id)
canEditEmblem (map key)
false (map value)
(FAILS HERE)

                
      was (Author: sdrulea):
    The problem code in flush() function of transport.js:
--------------------------------------------------------
flush: function() {
    var out = new Buffer(this.outCount),
        pos = 0;
    this.outBuffers.forEach(function(buf) {
      buf.copy(out, pos, 0);
      pos += buf.length;
    });

copy() on line 119 is being on a primitive (false from the example code above).

Here's the stack trace of line 119 buf sent to copy() from the example code:

setTeamPrivileges (function name)
xbox (platform)
ops2 (title_id)
canEditEmblem (map key)
false (map value)
(FAILS HERE)

                  
> 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
>
> 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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to