#1652·ioredis

`undefined` key is treated as `''`

Author: jmcdo29Created Sep 15, 2022Updated Aug 28, 2026
Labelsstale

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

bash
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.