morrySnow opened a new pull request, #67816:
URL: https://github.com/apache/doris/pull/67816

   ### What problem does this PR solve?
   
   Metadata REST endpoints can mishandle large pagination values in three ways:
   
   - An offset beyond the available list is clamped to the final item instead 
of producing an empty page.
   - Adding large limit and offset integers can overflow and create an invalid 
sub-list range.
   - Values outside the integer range raise parsing exceptions that are 
reported as internal errors.
   
   The behavior affects both the legacy metadata routes and the v2 metadata 
routes. It can be reproduced by requesting a metadata list with a very large 
offset, with both limit and offset set to the maximum integer, or with a 
pagination value larger than the supported numeric range.
   
   ### What is the root cause?
   
   Both controllers contain duplicate pagination logic based on int parsing and 
direct limit-plus-offset arithmetic. The lower bound is also capped at size 
minus one, which turns a past-the-end offset into the last element.
   
   ### What changes are included?
   
   - Add one shared pagination helper for both controller versions.
   - Parse non-negative values as long integers and map malformed or 
unsupported values to a stable bad-request response.
   - Return the half-open empty range at the list size when the offset reaches 
or exceeds the end.
   - Compute the upper bound from the remaining item count, avoiding 
overflow-prone addition.
   - Add focused unit tests and HTTP regression coverage for both route 
versions.
   
   ### Release note
   
   Fix metadata REST pagination for large and invalid limit or offset values.
   
   ### Check List (For Author)
   
   - Test: Unit Test and Regression Test
   - Behavior changed: Yes. Out-of-range offsets now return an empty page, and 
invalid pagination values return a stable bad-request response.
   - Does this need documentation: No


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to