markhoerth opened a new issue, #14425:
URL: https://github.com/apache/gravitino/issues/14425
### Version
main branch, commit bb634defdc5663a8124be5fca1c8d9e52ac096ac (2.0.0-SNAPSHOT)
### Describe what's wrong
A client of the Lance REST service sends a request that Jersey itself
rejects before any Gravitino handler runs: `POST /v1/table/{id}/create` with
`Content-Type: application/json` instead of
`application/vnd.apache.arrow.stream`, or `GET
/v1/namespace/{id}/table/list?limit=x`. The client expects a 4xx (415
Unsupported Media Type for the first, 400 for the bad query parameter). Instead
the service returns 500 with error code 18 ("Internal server error") and no
detail, so the client cannot tell its own mistake from a server failure.
The cause is in
`lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/LanceExceptionMapper.java:98-124`.
The mapper is registered for every `Throwable` (`:49`), and
`toLanceNamespaceException` only recognizes Gravitino and Java exception types.
JAX-RS `WebApplicationException` subclasses
(`javax.ws.rs.NotSupportedException`,
`org.glassfish.jersey.server.ParamException$QueryParamException`) fall into the
final `else` at `:121-123` and become `InternalException`, which maps to 500.
Their own HTTP status is discarded.
### Error message and/or stacktrace
```
POST /lance/v1/table/cat$s$t2/create Content-Type: application/json
{"schema":"x"}
500 {"error":"Internal server error","code":18,"detail":"","instance":""}
server log:
LanceExceptionMapper.toLanceNamespaceException(LanceExceptionMapper.java:122) -
Lance REST server unexpected exception:
javax.ws.rs.NotSupportedException: HTTP 415 Unsupported Media Type
GET /lance/v1/namespace/cat$s/table/list?limit=x
500 {"error":"Internal server error","code":18,"detail":"","instance":""}
server log: org.glassfish.jersey.server.ParamException$QueryParamException:
HTTP 404 Not Found
```
### How to reproduce
1. Start the Gravitino server with the Lance REST service, with
`gravitino.lance-rest.gravitino-metalake` pointing at an existing metalake
(`lml` below).
2. Create a `lakehouse-generic` catalog and a namespace:
```
curl -u admin:x -H 'Content-Type: application/json' -H 'Accept:
application/vnd.gravitino.v1+json' -X POST
http://127.0.0.1:8090/api/metalakes/lml/catalogs -d
'{"name":"cat","type":"RELATIONAL","provider":"lakehouse-generic","comment":"","properties":{"location":"file:///tmp/lance_cat"}}'
curl -u admin:x -H 'Content-Type: application/json' -X POST
'http://127.0.0.1:9101/lance/v1/namespace/cat$s/create' -d
'{"mode":"create","properties":{}}'
```
3. Send a create with a JSON body; the response is 500:
```
curl -u admin:x -H 'Content-Type: application/json' -X POST
'http://127.0.0.1:9101/lance/v1/table/cat$s$t2/create' -d '{"schema":"x"}'
```
4. List with a non-numeric limit; the response is 500:
```
curl -u admin:x
'http://127.0.0.1:9101/lance/v1/namespace/cat$s/table/list?limit=x'
```
### Additional context
Related: #14204 (unmatched routes hit the same mapper gap). The 2.0 OSS test
suite checks `test_create_with_json_body_is_415` and
`test_non_numeric_limit_is_400` found it. The defect is in Gravitino's Lance
exception mapper.
--
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]