Repository navigation
[Server] Test every ErrorCode's response on UC REST, Iceberg and Delta - #2049
Merged
Merged
Conversation
Add ErrorCodeTest, which runs every ErrorCode through the three exception handlers (GlobalExceptionHandler, IcebergRestExceptionHandler and DeltaApiExceptionHandler) and checks the HTTP status, the status echoed in the body and the error type each one returns: - UC REST: status and error_code - Iceberg REST: status, ErrorResponse code and type - Delta: status, error.code and error.type The expected responses come from an exhaustive switch over ErrorCode, so a new error code does not compile until its responses on all three APIs are written down, and a change to any existing mapping fails the test. The table also pins the deliberate differences between the APIs: the legacy *_ALREADY_EXISTS codes answer 400 on UC REST but 409 on Delta (and on Iceberg for schema and table), and UNPROCESSABLE_ENTITY is a 422 on Iceberg but a 400 on Delta. With the mapping covered in one place, drop the per-handler assertions from ManagedTableCleanupTaskTest.dropBlockedByCommitLockIsUnavailable. It still checks that the drop fails as UNAVAILABLE, and ErrorCodeTest covers how each API reports that code. Closes unitycatalog#2043 Signed-off-by: NopeCharon <[email protected]>
Collaborator
|
/review |
yili-db
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
docsis updated (not needed, test-only change)Description of changes
Closes #2043.
#2008 added per-handler assertions to
ManagedTableCleanupTaskTest.dropBlockedByCommitLockIsUnavailablefor how one error code (UNAVAILABLE) reaches clients on each API. This PR replaces those with a single test that pins the response for everyErrorCodeon all three APIs.Changes:
server/src/test/java/io/unitycatalog/server/exception/ErrorCodeTest. It runs everyErrorCode(@EnumSource) throughGlobalExceptionHandler,IcebergRestExceptionHandlerandDeltaApiExceptionHandler, and checks:error_codeErrorResponsecodeandtypeerror.codeanderror.typeswitchoverErrorCode. A new error code therefore won't compile until its responses on all three APIs are written down, and changing any existing mapping fails the test. The table also documents the intended differences between the APIs:*_ALREADY_EXISTScodes are 400 on UC REST and 409 on Delta. On Iceberg,SCHEMA_ALREADY_EXISTSandTABLE_ALREADY_EXISTSare 409, and the other legacy codes are 400.UNPROCESSABLE_ENTITYis 422 on Iceberg and 400 (InvalidParameterValueException) on Delta.dropBlockedByCommitLockIsUnavailabledrops its per-handler assertions and theerrorResponsehelper. It still checks that the drop fails asUNAVAILABLE.No production code changes.
Tests:
build/sbt "server/javafmtCheckAll" "server/testOnly io.unitycatalog.server.exception.ErrorCodeTest io.unitycatalog.server.persist.ManagedTableCleanupTaskTest": 27 + 7 tests passed, format check clean.UNAVAILABLEto 500 inErrorCode.ErrorCodeTestthen failed for that code (expected: 503). I reverted the change.