Subham-KRLX opened a new pull request, #5874:
URL: https://github.com/apache/couchdb/pull/5874

   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 a new EUnit test suite 
   src/chttpd/test/eunit/chttpd_all_docs_range_test.erl
    which verifies the fix.
   
   To test manually:
   
   Create a database.
   Issue a request with an inverted range:
   bash
   curl -v "http://localhost:5984/db/_all_docs?startkey=\"z\"&endkey=\"a\"";
   Verify that the response is 400 Bad Request with the error message described 
above.
   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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to