ioredis icon indicating copy to clipboard operation
ioredis copied to clipboard

`undefined` key is treated as `''`

Open jmcdo29 opened this issue 2 years ago • 0 comments

Current Behavior

ioredis will treat a key of undefined the same as the key '', meaning you can call redis.set(undefined, 'some value') and later use redis.get('') to get 'some value' from the redis instance.

Expected Behavior

ioredis either throws an error that undefined was passed when there should be an explicit string or Buffer, or it is documented that ioredis will automatically convert the undefined to ''.

Minimum Reproduction Repository

https://github.com/jmcdo29/ioredis-undefined-key

Reproduction steps

git clone [email protected]:jmcdo29/ioredis-undefined-key.git
cd ioredis-undefined-key
pnpm i
docker compose up -d
node index.js
docker compose down

Observe the assertion failure from notEqual() in the getBlankStringKey method.

jmcdo29 avatar Sep 15 '22 18:09 jmcdo29