Skip to content
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

Make 404 responses compatible with CouchDB API #56

Merged

Conversation

bajtos
Copy link
Contributor

@bajtos bajtos commented Mar 13, 2014

The CouchDB REST API returns always "error": "not_found" in the body of a 404 response:
http://couchdb-13.readthedocs.org/en/latest/api-basics/#http-status-codes

The npm client depends on the magic string 'not_found' as can be seen
in requestDone() in npm-registry-client/lib/request.js.

Before this change, npm install of an unknown package was reporting
the Sinopia error string and a stack trace of npm:

npm http GET http://localhost:4873/does-not-exist
npm http 404 http://localhost:4873/does-not-exist
npm ERR! Error: no such package available : does-not-exist
npm ERR!     at RegClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:237:14)
npm ERR!     at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:123:22)
npm ERR!     at Request.EventEmitter.emit (events.js:98:17)
npm ERR!     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:893:14)
npm ERR!     at Request.EventEmitter.emit (events.js:117:20)
npm ERR!     at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:844:12)
npm ERR!     at IncomingMessage.EventEmitter.emit (events.js:117:20)
npm ERR!     at _stream_readable.js:920:16
npm ERR!     at process._tickCallback (node.js:415:13)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

After this change, npm install of an unknown package returns a nice
error saying "the package is not in the npm registry, bug the author"

npm http GET http://localhost:4873/does-not-exist
npm http 404 http://localhost:4873/does-not-exist
npm ERR! 404 'does-not-exist' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.

The CouchDB REST API returns always `"error": "not_found"` in the body
of a 404 response:
  http://couchdb-13.readthedocs.org/en/latest/api-basics/#http-status-codes

The npm client depends on the magic string 'not_found' as can be seen
in requestDone() in npm-registry-client/lib/request.js.

Before this change, npm install of an unknown package was reporting
the Sinopia error string and a stack trace of npm.

After this change, npm install of an unknown package returns a nice
error saying "the package is not in the npm registry, bug the author"
rlidwka added a commit that referenced this pull request Mar 13, 2014
Make 404 responses compatible with CouchDB API
@rlidwka rlidwka merged commit 0afd9d1 into rlidwka:master Mar 13, 2014
@rlidwka
Copy link
Owner

rlidwka commented Mar 13, 2014

Thanks, looks good to me.

rlidwka added a commit that referenced this pull request Mar 13, 2014
@rlidwka
Copy link
Owner

rlidwka commented Mar 13, 2014

... and published as 0.7.0 with a lot of other changes...

@bajtos
Copy link
Contributor Author

bajtos commented Mar 13, 2014

Awesome 👍

@bajtos bajtos deleted the fix-unknown-package-name-response branch March 14, 2014 08:12
rlidwka added a commit that referenced this pull request Mar 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants