Skip to content

Fix Error on inverted range for _all_docs#5956

Open
yaxit24 wants to merge 1 commit intoapache:mainfrom
yaxit24:fix-5866-all-docs-range
Open

Fix Error on inverted range for _all_docs#5956
yaxit24 wants to merge 1 commit intoapache:mainfrom
yaxit24:fix-5866-all-docs-range

Conversation

@yaxit24
Copy link
Copy Markdown

@yaxit24 yaxit24 commented Mar 31, 2026

Overview

If a _view has an impossible start_key/end_key combination, CouchDB returns a helpful 400 query_parse_error. However, _all_docs lacked this validation and would silently return 200 with an empty result set {"rows":[]}.

Testing recommendations

You can verify this locally using curl:

Before this PR (returns 200 with empty rows): curl -X GET "http://127.0.0.1:5984/mydb/_all_docs?startkey=\"z\"&endkey=\"a\""

After this PR (returns 400): curl -X GET "http://127.0.0.1:5984/mydb/_all_docs?startkey=\"z\"&endkey=\"a\""

Related Issues or Pull Requests

issue #5866

Checklist

  • This is my own work, I did not use AI, LLM's or similar technology
  • [☑️] Code is written and works correctly
  • [☑️] Changes are covered by tests
  • Any new configurable parameters are documented in rel/overlay/etc/default.ini
  • Documentation changes were made in the src/docs folder
  • Documentation changes were backported (separated PR) to affected branches

When a _view request has an impossible start_key/end_key combination,
CouchDB returns a 400 Bad Request with query_parse_error. This adds
the same validation to _all_docs.

Uses check_range function in couch_mrview_util. Added tests spanning
both the HTTP API clustered path and direct Erlang MRView API.
@yaxit24 yaxit24 changed the title Fix #5866: Error on inverted range for _all_docs Fix Error on inverted range for _all_docs Mar 31, 2026
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.

1 participant