Skip to content

fix(gax-httpjson): gracefully handle error details with unrecognized types - #14612

Open
whowes wants to merge 1 commit into
mainfrom
whowes/preserve-proto-errors
Open

whowes wants to merge 1 commit into
mainfrom
whowes/preserve-proto-errors

Conversation

@whowes

@whowes whowes commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Currently HTTP/JSON error responses that include unrecognized protos (e.g. service specific, including non-GCP) in error.details fail with InvalidProtocolBufferException during proto conversion. This results in the user receiving an empty Status and losing the top-level error message and any recognized google.rpc.* error details.

To avoid this loss, this change filters error.details before proto conversion so only entries with a @type registered in STANDARD_ERROR_TYPES are passed to JsonFormat.Parser. The JSON from filtered-out details is still visible to the user in stack traces.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates HttpJsonErrorParser to filter out unrecognized or malformed error details from the JSON payload before parsing it into a Status object, ensuring only recognized standard error types are processed. It also adds unit tests to verify this behavior. Feedback was provided to replace JsonArray.asList() with JsonArray.iterator() to maintain backward compatibility with older Gson versions and prevent potential NoSuchMethodError runtime exceptions.

@whowes
whowes force-pushed the whowes/preserve-proto-errors branch 2 times, most recently from ce6bbb6 to dc192fc Compare October 9, 2026 17:33
@whowes
whowes force-pushed the whowes/preserve-proto-errors branch from dc192fc to c60c8c1 Compare October 12, 2026 18:27
@whowes
whowes marked this pull request as ready for review October 12, 2026 18:36
@whowes
whowes requested a review from a team as a code owner October 12, 2026 18:36
@whowes
whowes requested a review from blakeli0 October 12, 2026 18:36
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

This branch has not been deployed

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