Skip to content

server: return protocol error bodies for HTTP failures - #92

Merged
littlegrasscao merged 10 commits into
mainfrom
server/split2/05-http-errors
Oct 19, 2026
Merged

littlegrasscao merged 10 commits into
mainfrom
server/split2/05-http-errors

Conversation

@littlegrasscao

@littlegrasscao littlegrasscao commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • render every failure as the protocol's {errorCode, message} JSON body through ApiExceptionHandler, an Armeria exception handler and decorator that any Armeria host can register
  • ApiFailure maps failures to a status, error code, and message:
    • ApiException keeps its own status and code
    • a missing asset is 404 RESOURCE_DOES_NOT_EXIST; a denied asset is 403 PERMISSION_DENIED; an unsupported asset type is 400 INVALID_PARAMETER_VALUE
    • CatalogAuthenticationException, a caller token the catalog cannot authenticate, is 401 UNAUTHENTICATED, with WWW-Authenticate: Bearer
    • CatalogAuthorizationException, a caller without the requested privilege, is 403 PERMISSION_DENIED
    • other catalog failures are 502 CATALOG_ERROR; unreadable bodies and illegal arguments are 400; uniqueness violations are 409 RESOURCE_ALREADY_EXISTS; anything else is 500 INTERNAL_ERROR
  • the local catalog reports a missing or unknown bearer token as CatalogAuthenticationException
  • the standalone server answers unknown routes with a 404 in the protocol's error format

Testing

  • mvn clean install: 65 tests passed
  • ApiFailureTest: every failure mapping, including 401 for catalog authentication failures
  • ApiExceptionHandlerTest: Armeria's own failures (unrouted requests, other statuses, unreadable bodies, invalid parameters), the JSON body, WWW-Authenticate on 401, and failures a service throws or its response fails with
  • UnknownRouteTest: an unknown route on the standalone server is a 404 with the protocol body
  • LocalCatalogConnectorTest: an unknown token is a CatalogAuthenticationException

Stacked on #91.

@littlegrasscao
littlegrasscao marked this pull request as ready for review September 15, 2026 18:56
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from 5aba83f to 93250a9 Compare September 16, 2026 21:51
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from 93250a9 to 5a34448 Compare September 22, 2026 16:42
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from 5a34448 to a849dc5 Compare September 25, 2026 22:26
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from a849dc5 to 34f17c2 Compare September 25, 2026 22:31
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from 34f17c2 to 6643c01 Compare September 25, 2026 22:37
@littlegrasscao
littlegrasscao requested a review from zhu-tom October 1, 2026 00:16
@zhu-tom
zhu-tom added this pull request to stack #111 October 1, 2026 18:55
@littlegrasscao
littlegrasscao removed this pull request from stack #111 October 1, 2026 20:19
@littlegrasscao
littlegrasscao added this pull request to stack #112 October 1, 2026 20:20
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch 2 times, most recently from 4ca0f12 to 257ea90 Compare October 2, 2026 16:40
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from 356aae1 to 32c2f78 Compare October 5, 2026 23:57
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from 32c2f78 to 614f257 Compare October 6, 2026 00:05
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from 614f257 to a313bfd Compare October 6, 2026 00:14
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from a313bfd to 7dc0c8b Compare October 6, 2026 00:31
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from af0ce28 to 2aae10c Compare October 8, 2026 00:44
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch 11 times, most recently from 2fe8844 to 8a4a275 Compare October 14, 2026 19:24
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from 8a4a275 to 4734c9f Compare October 19, 2026 17:12
Base automatically changed from server/split2/04-storage-paths to main October 19, 2026 22:30
@littlegrasscao
littlegrasscao force-pushed the server/split2/05-http-errors branch from 4734c9f to 9bbdbd8 Compare October 19, 2026 22:30
@littlegrasscao
littlegrasscao merged commit 830216c into main Oct 19, 2026
1 check 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.

2 participants