Selecting empty/null collection columns cause "Cannot read property 'length' of null" exceptions #136

Closed
Oleg12 opened this Issue Jan 28, 2014 · 5 comments

Projects

None yet

3 participants

@Oleg12

Helenus 0.6.8, Cassandra 1.2.13

Keyspace/table defined like this (used cqlsh to create them):
CREATE KEYSPACE olegr_test WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'els' :'3'};
CREATE TABLE olegr_test.t1 (key int PRIMARY KEY, fl LIST, fs SET, fm MAP, reg int);

Add a single row to the table:
INSERT INTO olegr_test.t1 (key, fl, fs, fm, reg) VALUES (1, [], {}, {}, null);

Then use Helenus to query map (or set or list) column (fm, fs or fl):
pool.cql("SELECT fm FROM olegr_test.t1 WHERE key = %s;", [1], function(error, result)
{
// Code to print error and/or result
});

Expected result: no exceptions, null is returned (as in case of quering for 'reg' column)

Actual result: exception
/home/oleg/cassandra-perf-test/node_modules/helenus/node_modules/helenus-thrift/lib/thrift/connection.js:90
throw e;
^
TypeError: Cannot read property 'length' of null
at new Buffer (buffer.js:184:31)
at /home/oleg/cassandra-perf-test/node_modules/helenus/lib/marshal/index.js:259:15
at new Row (/home/oleg/cassandra-perf-test/node_modules/helenus/lib/row.js:50:35)
at onReturn (/home/oleg/cassandra-perf-test/node_modules/helenus/lib/connection.js:472:19)
at onReturn (/home/oleg/cassandra-perf-test/node_modules/helenus/lib/connection.js:406:7)
at client._reqs.(anonymous function) (/home/oleg/cassandra-perf-test/node_modules/helenus/node_modules/helenus-thrift/lib/thrift/connection.js:80:11)
at Object.CassandraClient.recv_execute_cql3_query (/home/oleg/cassandra-perf-test/node_modules/helenus/lib/cassandra/Cassandra.js:8343:12)
at /home/oleg/cassandra-perf-test/node_modules/helenus/node_modules/helenus-thrift/lib/thrift/connection.js:83:37
at Socket. (/home/oleg/cassandra-perf-test/node_modules/helenus/node_modules/helenus-thrift/lib/thrift/transport.js:70:9)
at Socket.EventEmitter.emit (events.js:95:17)

Adding the following line
if (str === null) return null;

right before creating new Buffer in mapDeserializer() and listDeserializer() in helenus/lib/marshal/index.js at lines 236 and 259 seems to help... but I am not familiar enough with the code to be sure that it is the right fix :-(

@devdazed devdazed closed this in 70593a2 Feb 17, 2014
@devdazed
SimpleReach member

This will go out in the next release. Thanks for the good find!

@raghukanchiraju

When is the next release? (what version?)

@devdazed
SimpleReach member

this will go out in 0.6.9, ill try to cut it later this week.

@Oleg12

Tried the fix, didn't work - 70593a2 uses 'val' in checks for null/undefined, probably should be 'str'?
ReferenceError: val is not defined
at .../node_modules/helenus/lib/marshal/index.js:236:8
at new Row (.../node_modules/helenus/lib/row.js:50:35)
at onReturn (.../node_modules/helenus/lib/connection.js:488:19)
at onReturn (.../node_modules/helenus/lib/connection.js:422:7)
at client._reqs.(anonymous function) (.../node_modules/helenus/node_modules/helenus-thrift/lib/thrift/connection.js:80:11)
at Object.CassandraClient.recv_execute_cql3_query (.../node_modules/helenus/lib/cassandra/Cassandra.js:8343:12)
at .../node_modules/helenus/node_modules/helenus-thrift/lib/thrift/connection.js:83:37
at Socket. (.../node_modules/helenus/node_modules/helenus-thrift/lib/thrift/transport.js:74:11)

@raghukanchiraju

Yes, please replace val with str for it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment