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

Fix response code for nonexistent attachment #3673

Merged

Conversation

noahshaw11
Copy link
Contributor

Overview

Currently, a DELETE request for a non existent attachment responds with a 200 OK even if the attachment is missing. This PR changes the response code for nonexistent attachments to a 404 NOT FOUND {"error":"not_found","reason":"Document is missing attachment"}

Testing recommendations

% curl -X PUT http://localhost:15984/demo/38 -H 'Authorization: Basic YWRtOnBhc3M=' -d '{"name": "whatever"}'
{"ok":true,"id":"38","rev":"1-a0f595984a7c4cf1dafc4cf4c04081d6"}
% curl -X DELETE 'http://adm:pass@localhost:15984/demo/38/notexisting.txt?rev=1-a0f595984a7c4cf1dafc4cf4c04081d6'
{"error":"not_found","reason":"Document is missing attachment"}

Related Issues or Pull Requests

Deleting not existing attachment responds 200 instead of 404: #2146

Checklist

  • Code is written and works correctly
  • Changes are covered by tests
  • Any new configurable parameters are documented in rel/overlay/etc/default.ini
  • A PR for documentation changes has been made in https://github.com/apache/couchdb-documentation

@noahshaw11 noahshaw11 force-pushed the fix-response-code-for-nonexistent-attachment branch from ad75714 to 8052a97 Compare July 19, 2021 16:40
@noahshaw11 noahshaw11 force-pushed the fix-response-code-for-nonexistent-attachment branch from 60a8792 to ea855f4 Compare July 19, 2021 17:26
Copy link
Contributor

@nickva nickva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Flaky test is flaky:

[2021-07-19T17:20:48.690Z] UsersDbTest

[2021-07-19T17:20:48.690Z]   * test users password requirements
  * test users password requirements (117.3ms)

[2021-07-19T17:20:54.751Z]   * test users db
  * test users db (5046.5ms)

[2021-07-19T17:20:54.751Z] 

[2021-07-19T17:20:54.751Z]   1) test users db (UsersDbTest)

[2021-07-19T17:20:54.751Z]      test/elixir/test/users_db_test.exs:104

[2021-07-19T17:20:54.751Z]      Assertion with != failed, both sides are exactly equal

[2021-07-19T17:20:54.751Z]      code: assert ddoc.body()["validate_doc_update"] != nil

[2021-07-19T17:20:54.751Z]      left: nil

[2021-07-19T17:20:54.751Z]      stacktrace:

[2021-07-19T17:20:54.751Z]        test/elixir/test/users_db_test.exs:108: (test)

Not related to the code. May have to just retry force pushing a few times

@nickva nickva merged commit f31e929 into apache:3.x Jul 19, 2021
@noahshaw11 noahshaw11 deleted the fix-response-code-for-nonexistent-attachment branch July 27, 2021 17:02
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