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

   ### Version
   
   main branch (2.0.0-SNAPSHOT, eb988d1)
   
   ### Describe what's wrong
   
   The Iceberg REST service answers two client errors with HTTP 500 instead of 
a 4xx, so clients
   treat a bad request as a server failure and retry it.
   
   `IcebergExceptionMapper.getErrorCode` looks up the exact exception class in 
`EXCEPTION_ERROR_CODES`
   
(`iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergExceptionMapper.java:102`)
   and falls back to 500 (`:109`). Two Iceberg exceptions are missing from that 
table:
   
   - `org.apache.iceberg.exceptions.NotFoundException`. The table maps 
`NotFoundException` to 404, but
     the class imported at `:23` is `javax.ws.rs.NotFoundException`, so 
Iceberg's own exception of the
     same simple name is not matched.
   - `java.lang.IllegalStateException`, which Iceberg throws when a schema is 
invalid for the table's
     format version.
   
   Affected requests:
   
   1. `registerTable` with `overwrite: true` and a `metadata-location` that 
does not exist. Iceberg
      throws `NotFoundException: Failed to open input stream for file` and the 
service returns 500.
   2. `createTable` with `format-version` 2 and a V3-only type (variant, 
timestamp_ns,
      timestamptz_ns, geometry). Iceberg throws `IllegalStateException: Invalid 
schema for v2` and the
      service returns 500.
   
   ### Error message and/or stacktrace
   
   ```
   HTTP 500 {"error":{"message":"Failed to open input stream for file: 
.../ns/a/metadata/00000-ffa1cbe4-....metadata.json.missing.json","type":"NotFoundException","code":500}}
   HTTP 500 {"error":{"message":"Invalid schema for v2:\n- Invalid type for 
doc: variant is not supported until 
v3","type":"IllegalStateException","code":500}}
   ```
   
   ### How to reproduce
   
   1. Start the server with the Iceberg REST service.
   2. Create a table, then register over it with a metadata file that does not 
exist:
      `POST /iceberg/v1/namespaces/ns/register` with
      `{"name": "t", "metadata-location": "<the table's current 
metadata-location>.missing.json", "overwrite": true}`.
      Expected 404 (or 400); actual 500.
   3. Create a table in format version 2 with a variant column:
      `POST /iceberg/v1/namespaces/ns/tables` with
      `{"name": "t2", "properties": {"format-version": "2"}, "schema": {"type": 
"struct", "schema-id": 0, "fields": [{"id": 1, "name": "doc", "required": 
false, "type": "variant"}]}}`.
      Expected 400; actual 500.
   
   ### Additional context
   
   Requirement: both requests return a 4xx with the Iceberg error model, and 
500 is left for
   server failures. Related: #11059 (registerTable overwrite), #13686 (mapper 
preserves
   WebApplicationException status).


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