Skip to content

[Server] Answer unrouted Iceberg requests with an Iceberg error document - #1836

Merged
yili-db merged 2 commits into
unitycatalog:mainfrom
moomindani:feat/iceberg-unrouted-errors
Sep 9, 2026
Merged

yili-db merged 2 commits into
unitycatalog:mainfrom
moomindani:feat/iceberg-unrouted-errors

Conversation

@moomindani

@moomindani moomindani commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Fixes #1835.

A request to an Iceberg REST path this server does not implement never reaches
IcebergRestCatalogService, so IcebergRestExceptionHandler never sees it and Armeria renders the
status itself as text/plain -- Status: 404 and a Description: line. Iceberg's
ErrorResponseParser cannot read that, so a client that does not consult the advertised endpoints
list gets an unparsable body where the REST spec puts an error document.

This registers a ServerErrorHandler on the Armeria server that renders those status-only responses
as an Iceberg ErrorResponse, and only for paths under the Iceberg API:

  • onServiceException returns null, so an exception raised by a service is still rendered by that
    service's own handler; nothing about the existing error paths changes.
  • renderStatus returns null unless the request path starts with the Iceberg API prefix, so
    non-Iceberg paths and / keep Armeria's rendering.
  • The prefix is built from the same ICEBERG_RELATIVE_PATH constant UnityCatalogServer mounts the
    service with, so the mount point and the handler cannot drift apart. It matches on a slash
    boundary, and matches the mount point itself as well as the paths under it, so
    GET /api/2.1/unity-catalog/iceberg is covered while a sibling path that merely starts with the
    same characters is not.
  • 404 is named NotFoundException; the remaining statuses have no Iceberg exception of their own and
    are named RESTException, which is what Iceberg's client raises for them.

For users: an Iceberg client that calls an endpoint this catalog does not implement now fails with
the exception the status means, instead of a parse error. Responses from implemented endpoints are
byte-for-byte unchanged.

Verified on main at 58d5c7b. Before, GET .../namespaces/{ns}/views answered
text/plain Status: 404\nDescription: Not Found\n and DELETE .../namespaces/{ns} answered
Status: 405\nDescription: Method Not Allowed\n; after, they answer
{"error":{"message":"Not Found","type":"NotFoundException","code":404}} and
{"error":{"message":"Method Not Allowed","type":"RESTException","code":405}} as
application/json. testUnroutedIcebergRequestsAnswerWithAnIcebergError fails on an unfixed tree
(expected: application/json but was: text/plain; charset=utf-8) and passes with the fix. It pins the
error type and message as well as the status -- NotFoundException for the 404 and
RESTException for the 405 -- the mount point itself, and two paths outside the Iceberg API: another
UC endpoint, and /, which still answers Hello, Unity Catalog!.
IcebergRestCatalogTest (10/10) and ArmeriaServerBuilderTest are green, and the full
server/test suite shows no failure attributable to this change.

A request to an Iceberg REST endpoint this server does not implement never reaches the Iceberg
service, so IcebergRestExceptionHandler never sees it and Armeria answers with its own plain-text
body, a "Status" line followed by a "Description" line. Iceberg's own ErrorResponseParser cannot read
that, so a client that does not consult the advertised endpoints list -- one written before that field
existed, or one that skips it -- gets an unreadable response where the REST spec puts an error
document.

Register a ServerErrorHandler that renders these status-only responses as an Iceberg ErrorResponse,
for paths under the Iceberg API only. Requests that reach a service keep being rendered by that
service's handler, and paths outside the Iceberg API keep Armeria's rendering, so nothing else on the
server changes. The prefix comes from the same constant the service is mounted with, so the two
cannot drift apart, and it matches the mount point itself as well as the paths under it, on a slash
boundary so that a sibling path starting with the same characters is not caught by it.

Signed-off-by: Noritaka Sekiyama <[email protected]>
@moomindani
moomindani force-pushed the feat/iceberg-unrouted-errors branch from bd56e3b to ff01411 Compare September 5, 2026 19:30

@Test
public void testUnroutedIcebergRequestsAnswerWithAnIcebergError() throws Exception {
createUniformIcebergTable();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setup looks unnecessary since none of the RPC calls below hits any actual endpoint.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed; you are right, every request there is answered before a service is reached, so nothing needs to exist. A comment says so instead.

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good fix. Just a minor comment.

Thank you!

Review follow-up. Every request in the test is answered before a service is
reached, so the catalog, schema and table it created were never involved; a
comment says so in their place.

Signed-off-by: Noritaka Sekiyama <[email protected]>
@yili-db
yili-db merged commit 29b0a14 into unitycatalog:main Sep 9, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Iceberg REST endpoints answer unimplemented paths with a body Iceberg clients cannot parse

2 participants