redis / node-redis

Redis Node.js client
https://redis.js.org/
MIT License
16.95k stars 1.89k forks source link

Handle null tuple for redisearch document #2856

Open jjsimps opened 1 month ago

jjsimps commented 1 month ago

Description

Recently, I updated to the latest version of RediSearch (2.10.7). I started getting a particular error that originates from within the redisearch library:

Cannot read properties of null (reading 'length') TypeError: Cannot read properties of null (reading 'length')
    at documentValue (/app/node_modules/.pnpm/@redis+search@1.2.0_@redis+client@1.6.0/node_modules/@redis/search/dist/commands/SEARCH.js:29:23)
    at Object.transformReply (/app/node_modules/.pnpm/@redis+search@1.2.0_@redis+client@1.6.0/node_modules/@redis/search/dist/commands/SEARCH.js:17:61)
    at transformCommandReply (/app/node_modules/.pnpm/@redis+client@1.6.0/node_modules/@redis/client/dist/lib/commander.js:89:20)
    at Commander.commandsExecutor (/app/node_modules/.pnpm/@redis+client@1.6.0/node_modules/@redis/client/dist/lib/client/index.js:190:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

This error seems to have originated from this change. Instead of returning an empty array [], None is returned. The library does not handle this case, and so the error is thrown.

This PR checks if the document is NULL, and if it is, return the object. This would give the same behavior as before.

I encountered this in the latest redis version (4.7). Not sure which branch I should be comitting to.


Checklist

jjsimps commented 2 weeks ago

Hey ya'll would be great to have some eyes on this :) Thank you!

leibale commented 1 week ago

I'm not sure what the value of this null element is, what should the user do with it? TBH it feels more like a bug in RediSearch...

leibale commented 1 week ago

Duplicate of #2814

jjsimps commented 1 week ago

@leibale Cool thanks. Should I close this MR then? Is there anything preventing a merge of the other one?