You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "Jens Geyer (Jira)" <ji...@apache.org> on 2026/10/14 21:53:00 UTC
[jira] [Created] (THRIFT-6409) Node.js TJSONProtocol loses nested list data after an empty inner list
Jens Geyer created THRIFT-6409:
----------------------------------
Summary: Node.js TJSONProtocol loses nested list data after an empty inner list
Key: THRIFT-6409
URL: https://issues.apache.org/jira/browse/THRIFT-6409
Project: Thrift
Issue Type: Bug
Components: Node.js - Library
Reporter: Jens Geyer
{{readListBegin()}} in {{lib/nodejs/lib/thrift/json_protocol.js}} moves the list's first element onto the reader's stack; for an empty list that element is {{undefined}}. {{readListEnd()}} pops one entry and then, if the enclosing list has elements left, moves the next one onto the stack. After a non-empty list the entry it pops is the list itself. After an empty list it is the {{undefined}} placeholder, and the emptied list stays behind. The enclosing levels then work one entry out of place, and a later list in the same container can take its element type and size from an emptied array, find neither, and be read as empty. No error is raised.
Round trips through the Node.js writer and reader on master (Node 20). The JSON written is correct; the wire form of the first value is shown below the table.
{noformat}
list<list<i32>> wrote [[],[],[1,2]] read [[],[],[]]
list<list<i32>> wrote [[1],[],[],[2]] read [[1],[],[],[]]
list<list<list<i32>>> wrote [[[1,2],[]],[],[[3]]] read [[[1,2],[]],[],[]]
map<i32,list<list<i32>>> wrote {0:[[],[]], 1:[[7]]} read {0:[[],[]], NaN:[]}
wire form of the first value: {"1":{"lst":["lst",3,["i32",0],["i32",0],["i32",2,1,2]]}}
{noformat}
In a randomised run of 3,000 values per type, with up to three elements per list, 136 of the {{list<list<i32>>}} values, 471 of the {{list<list<list<i32>>>}} values and 1,125 of the map values came back different. {{readListEnd()}} has worked this way since THRIFT-3748 (0.10.0).
Proposed change: have {{readListEnd()}} return the stack to the depth {{readListBegin()}} found, whether or not the list had elements, before it moves on to the enclosing list's next element, and add round-trip tests with empty inner lists at several depths.
_Drafted with AI assistance (Claude Opus 5.5); reviewed and filed by Jens Geyer._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)