Skip to content

Conversation

@Subham-KRLX
Copy link

@Subham-KRLX Subham-KRLX commented Jan 30, 2026

This PR implements a validation check for _all_docs requests to ensure that start_key is not greater than end_key (or vice versa when descending=true).

Previously, _all_docs queries with inverted ranges would return empty results without a clear indication of the error. This change aligns the behavior of _all_docs with _view, which already rejects inverted ranges with a 400 Bad Request.

Users providing an invalid range will now receive the following error:

{"error":"query_parse_error","reason":"No rows can match your key range, reverse your start_key and end_key or set descending=true"}
Testing recommendations
I have added two new test cases to the existing
src/chttpd/test/eunit/chttpd_view_test.erl
suite:

t_all_docs_with_inverted_range - verifies 400 error for inverted ranges
t_all_docs_with_inverted_range_descending - verifies correct behavior with descending=true
Manual testing can be done by querying _all_docs with an inverted range and verifying the 400 response.

Related Issues or Pull Requests
Fixes #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

@Subham-KRLX Subham-KRLX marked this pull request as draft January 30, 2026 17:39
@rnewson
Copy link
Member

rnewson commented Jan 30, 2026

Please complete the PR template correctly, and specifically to confirm that this is your work and not the output of an LLM tool.

The tests should be added to existing test suites, the one you have written (or generated) contains a lot of duplication from elsewhere and will not be accepted.

- Add tests to chttpd_view_test.erl instead of separate file
- Remove duplicate test file
- Address maintainer feedback
Address maintainer feedback by integrating tests into existing suite
@Subham-KRLX
Copy link
Author

I have addressed both of your concerns by confirming in the PR template that this is my own work and moving the tests into the existing
chttpd_view_test.erl
suite as requested. However iam unable to properly debug the remaining test failures without a local Erlang environment to run and verify the changes. I will close this PR for now and may revisit this issue once I have the proper development setup to test changes locally Thank you for your time reviewing this contribution.

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.

[ENHANCEMENT]: send error message for inverted range for _all_docs as we do for _view

2 participants