Calling kue.Job.get() with undefined or null causes uncaught exception
- Dominant language
- JavaScript
- Stars
- 9.4k
- Forks
- 858
- PR merge metrics
- No merged PRs in 30d
Description
Calling `kue.Job.get()` and passing an undefined or null `id` causes an uncaught exception:
```
FATAL: UncaughtException: Cannot read property 'toString' of undefined TypeError: Cannot read property 'toString' of undefined
at Redis.client.createFIFO (/app/node_modules/kue/lib/redis.js:82:26)
at Function.exports.get (/app/node_modules/kue/lib/queue/job.js:173:20)
```
from this entry point: https://github.com/Automattic/kue/blob/master/lib/queue/job.js#L161
the `get()` function does `job.zid = client.createFIFO(id);`.
The uncaught exception happens on this line in `createFIFO()`: (https://github.com/Automattic/kue/blame/master/lib/redis.js#L82)
```
var idLen = '' + id.toString().length;
```
Granted, it shouldn't be passing in `undefined` as `id` to `Job.get()` initially, and I can add a check to make sure that doesn't happen in my app code.
That being said, it might be better not to allow this use case to generate an uncaught exception in the Kue code, and instead call the return fn with a validation error
Contributor guide
No contributing guide indexed for this repository
Research direction
Read lib/queue/job.js around Job.get() and lib/redis.js around createFIFO(), then reproduce the null and undefined calls. Done means those inputs no longer cause an uncaught exception and the return callback receives a validation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, redis
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100