restify / restify/node-restify
unexpected error code for 'ResourceNotFoundError'
Open
Nobody has claimed this yet.
Bug
Critical
Unconfirmed
Waiting on Response
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 975
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 5
Description
Bug Report
Restify Version
5.2.0
Node.js Version
7.10.1
Expected behaviour
// trigger this error when some in-existing route being called
server.on('NotFound', (req, res, err, cb) => {
if (err instanceof errors.ResourceNotFoundError) {
// should get here
}
cb();
});
Actual behaviour
// trigger this error when some in-existing route being called
server.on('NotFound', (req, res, err, cb) => {
req.log.info(JSON.stringify(err, null, 2)); // { "code": "ResourceNotFound", "message": "/xxxx does not exist" }
req.log.info(err.toString()); // ResourceNotFoundError: /xxxx does not exist
req.log.info(err.code); // Error
if (err instanceof errors.ResourceNotFoundError) {
// never get here
}
cb();
});
Repro case
- create a error handler for
NotFounderror (though I assume there should have aResourceNotFoundError) - call API server with an in-existing route.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the server.on('NotFound') handler and reproduce a request to an in-existing route with the reported Restify and Node.js versions. Trace where ResourceNotFoundError is created and how its code is assigned; done means the handler receives the expected error instance and behavior, with a regression test covering the repro.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100