jiangxt2 opened a new issue, #13185:
URL: https://github.com/apache/gravitino/issues/13185

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   Lance REST pagination can fail when a valid page token from an earlier 
request is combined with a large positive `limit`, including 
`Integer.MAX_VALUE`.
   
   `PageUtil.splitPage` calculates `startIndex + pageSize` using `int` 
arithmetic before clamping the result to the number of items. When the sum 
overflows, the end index becomes negative and the list operation fails instead 
of returning the remaining page.
   
   ### Error message and/or stacktrace
   
   The Lance REST endpoint returns HTTP 400 with an error similar to:
   
   ```text
   fromIndex(1) > toIndex(-2147483648)
   ```
   
   With the default configuration, the response detail includes a stack trace 
pointing to `PageUtil.splitPage` at the `subList` call.
   
   ### How to reproduce
   
   1. For a concrete reproduction, run the Gravitino 1.3.0 server together with 
the corresponding Gravitino 1.3.0 Lance REST service image 
(`apache/gravitino:1.3.0` and `apache/gravitino-lance-rest:1.3.0`, 
respectively; an equivalent registry mirror was used for the reproduction), 
configure the Lance REST service to point to the Gravitino server, and create a 
metalake containing at least two lakehouse-generic catalogs. The same 
pagination code path is present on the main branch, and the standalone service 
setup is documented in `docs/lance-rest-service.md`.
   2. Request the first page from the root namespace with a limit of one:
   
      ```text
      GET /lance/v1/namespace/list?limit=1
      ```
   
      The response contains one namespace and a page token of `1`.
   3. Request the next page with the returned token and the maximum positive 
integer limit:
   
      ```text
      GET /lance/v1/namespace/list?page_token=1&limit=2147483647
      ```
   
   4. Observe the HTTP 400 response and the negative `toIndex` in the error 
message.
   
   For comparison, using `limit=2147483646` with the same token returns the 
remaining namespace successfully.
   
   ### Additional context
   
   The pagination helper is shared by namespace and table listing operations, 
so both list operations are affected. The endpoint accepts positive integer 
limits up to `Integer.MAX_VALUE` and does not enforce a server-side maximum, so 
a request for the remaining items should return them instead of failing.
   


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