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

Revert "fix(mango): GET invalid path under _index should not cause 500 #4584

Merged
merged 1 commit into from
May 9, 2023

Conversation

rnewson
Copy link
Member

@rnewson rnewson commented May 9, 2023

This reverts commit c1195e4.

This wasn't quite right. handle_index_req has several separate resources handled within it which each support a different set of http methods.

We should send 405 for a resource that exists but doesn't support the request's method.
We should send 404 for a resource that doesn't exist at all.

Reverting this gives us a 500 / function_clause, which is at least honest (the server has made an error) but we should circle back and send better errors.

Noting that;

  1. extra paths for _all_docs gives the desired 404 but for a silly reason (it matches the clause that looks for attachments, and you can't make a doc called _all_docs to attach anything to)
  2. extra paths for _changes are ignored (and the _changes request works as expected) because handle_changes_req doesn't insist on a pattern for path_parts

In conclusion, we handle invalid paths in request handlers inconsistently, which ironically frees us to do the right thing in handle_index_req

@rnewson rnewson merged commit 2543590 into main May 9, 2023
@rnewson rnewson deleted the revert-invalid-path-fix branch May 9, 2023 18:00
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

1 participant