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

Review use of Http 417 status code #48

Open
gothub opened this issue Jul 6, 2020 · 2 comments
Open

Review use of Http 417 status code #48

gothub opened this issue Jul 6, 2020 · 2 comments
Assignees

Comments

@gothub
Copy link
Collaborator

gothub commented Jul 6, 2020

Several of the bookkeeper services return Http status 417 (Expectation Failed), which isn't consistent with the error that occurred.

Consider using one of these Http status codes:

  • 404 Not Found
  • 500 Internal Server Error
  • 503 Service Unavailable

Here is a sample request/response:

GET /bookkeeper/v1/quotas?quotaType=portal&subscribers=foo&requestor=http://orcid.org/0000-0002-2192-403X HTTP/1.1

{"code":417,"message":"The requested quotas couldn't be listed: http://orcid.org/0000-0002-2192-403X requested subscribers that don't exist or requestor doesn't have privilege to view them."}

For this case, where there was not an internal error (e.g. no SQL Error), status 404 seems the most appropriate.

In other instances, 417 is returned if any exception is thrown. In these cases, 500 may be more appropriate.

@gothub gothub self-assigned this Jul 6, 2020
@gothub gothub mentioned this issue Jul 8, 2020
@gothub
Copy link
Collaborator Author

gothub commented Jul 9, 2020

Changed 417 status codes to 500 in commit ede0e88

@gothub gothub closed this as completed Jul 9, 2020
@taojing2002
Copy link
Contributor

Hi @gothub, when I ran this command which includes a non-existent subscriber CN=opc-1,DC=dataone,DC=org:

curl -H "X-DataONE-Subscriber: CN=opc-1,DC=dataone,DC=org" -H "Authorization: Bearer ${token}" -F "object=@portal.xml" -F "sysmeta=@sysmeta-portal.xml" -F "pid=jing.27.1" -X POST https://mn-stage-ucsb-2.test.dataone.org/metacat/d1/mn/v2/object/

Bookkeeper returned 403 (forbidden) rather than 404

{"code":403,"message":"The requested subscribers don't exist or requestor doesn't have privilege to view them."}

@taojing2002 taojing2002 reopened this Jul 25, 2020
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

No branches or pull requests

2 participants