Skip to content

fix(rest): align error handlers with Java implementation#763

Merged
wgtmac merged 4 commits into
apache:mainfrom
zhjwpku:align_error_handlers
Jun 23, 2026
Merged

fix(rest): align error handlers with Java implementation#763
wgtmac merged 4 commits into
apache:mainfrom
zhjwpku:align_error_handlers

Conversation

@zhjwpku

@zhjwpku zhjwpku commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

While reviewing #614, I noticed that PlanErrorHandler::Accept does not match the behavior of the Java implementation.

A detailed comparison with Java's ErrorHandlers revealed several gaps between iceberg-cpp and Iceberg Java. Some of these are oversights in the original implementation, while others correspond to improvements that were made later in Iceberg Java, including:

This PR closes those gaps and brings the error handling behavior in iceberg-cpp closer to the Java implementation.

Comment thread src/iceberg/catalog/rest/error_handlers.cc Outdated
IsError(ErrorKind::kNoSuchPlanTask));
}

TEST(ErrorHandlersTest, OAuthErrorHandlerMapsInvalidClientToNotAuthorized) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add one test that goes through the OAuth error parsing path, not just OAuthErrorHandler::Accept with a prebuilt ErrorResponse? Otherwise this won't catch regressions in the new TryParseOAuthErrorResponse logic or accidentally using the default handler for token requests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good. I'll add a test to cover this path.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added a test that exercises OAuthErrorHandler::ParseResponse with an OAuth error body, then verifies the parsed response maps correctly through Accept.

@huan233usc huan233usc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mostly LGTM, thank you!

Comment thread src/iceberg/catalog/rest/http_client.cc Outdated
}
auto parse_result = TryParseErrorResponse(response.text);
auto parse_result =
dynamic_cast<const OAuthErrorHandler*>(&error_handler) != nullptr

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This looks a bit ugly. Maybe we should add a parseResponse interface to ErrorHandler, similar to the Java impl.

@wgtmac WDYT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That sounds good to me

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done that way.

zhjwpku added 4 commits June 22, 2026 19:31
While reviewing apache#614, I noticed that `PlanErrorHandler::Accept`
does not match the behavior of the Java implementation.

A detailed comparison with Java's `ErrorHandlers` revealed several
gaps between iceberg-cpp and Iceberg Java. Some of these are
oversights in the original implementation, while others correspond
to improvements that were made later in Iceberg Java, including:

* apache/iceberg#13143
* apache/iceberg#14927
* apache/iceberg#15051
* apache/iceberg#16059

This PR closes those gaps and brings the error handling behavior in
iceberg-cpp closer to the Java implementation.
@zhjwpku zhjwpku force-pushed the align_error_handlers branch from 78e88d1 to 29a2a72 Compare June 22, 2026 11:36
@zhjwpku zhjwpku added the ready to review This PR is ready to review with all previous comments addressed. label Jun 22, 2026
@wgtmac wgtmac removed the ready to review This PR is ready to review with all previous comments addressed. label Jun 23, 2026
@wgtmac

wgtmac commented Jun 23, 2026

Copy link
Copy Markdown
Member

Thanks @zhjwpku for working on this and @huan233usc for the review!

@wgtmac wgtmac merged commit 5c8c4e5 into apache:main Jun 23, 2026
20 checks passed
@zhjwpku zhjwpku deleted the align_error_handlers branch June 23, 2026 05:44
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.

3 participants