Skip to content

missing parameters are silently converted to an empty string #1898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Flarna opened this issue Feb 7, 2022 · 2 comments
Closed

missing parameters are silently converted to an empty string #1898

Flarna opened this issue Feb 7, 2022 · 2 comments
Labels

Comments

@Flarna
Copy link

Flarna commented Feb 7, 2022

If I use wrong number of arguments like set("foo") no error/failure is reported instead an empty string is written to redis.

Seems to be caused by the changed done in #1849.

Before the change above I got following exception which is also not that nice but at least no silent overwrite.

TypeError: Cannot read property 'length' of undefined
    at encodeCommand (C:\work\redis-4\node_modules\@node-redis\client\dist\lib\commander.js:71:104)
    at encodeCommand.next (<anonymous>)
    at RedisSocket.writeCommand (C:\work\redis-4\node_modules\@node-redis\client\dist\lib\client\socket.js:56:20)
    at Commander._RedisClient_tick (C:\work\redis-4\node_modules\@node-redis\client\dist\lib\client\index.js:435:64)
    at Commander._RedisClient_sendCommand (C:\work\redis-4\node_modules\@node-redis\client\dist\lib\client\index.js:416:82)
    at Commander.commandsExecutor (C:\work\redis-4\node_modules\@node-redis\client\dist\lib\client\index.js:166:154)
    at Commander.BaseClass.<computed> [as set] (C:\work\redis-4\node_modules\@node-redis\client\dist\lib\commander.js:8:29)
    at test (C:\work\redis-4\test.js:15:22)

I would expect to get an error like ERR wrong number of arguments for 'set' command like in redis-cli.

Environment:

  • Node.js Version: 14.19.0
  • Redis Server Version: 2.8.2400
  • Node Redis Version: 4.0.3
  • Platform: Windows 10
@Flarna Flarna added the Bug label Feb 7, 2022
@leibale
Copy link
Contributor

leibale commented Feb 10, 2022

The actual problem is that SET.transformArguments pushes value into the array arguments even if its undefined.

@leibale
Copy link
Contributor

leibale commented May 4, 2022

Fixed in 4.1.0

@leibale leibale closed this as completed May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants