Skip to content

[sdk-platform-java] Handle google.rpc.ErrorInfo in HttpJson*Stub class #12465

Open

Description

@JoeWang1127

Followup on googleapis/java-spanner#2229.

The generated HttpJsonEchoStub can't handle message type: google.rpc.ErrorInfo introduced by echo.proto (version 0.29.0).
A easy integration test:

@Test
public void testEchoErrorDetails() {
  EchoErrorDetailsResponse response = httpjsonClient.echoErrorDetails(
      EchoErrorDetailsRequest
          .newBuilder()
          .setSingleDetailText("singleDetailText1774380934")
          .addAllMultiDetailText(new ArrayList<>())
          .build());
  assertThat(response.hasSingleDetail()).isEqualTo(true);
}

failed with the following error message:

Caused by: com.google.protobuf.InvalidProtocolBufferException: Cannot resolve type: type.googleapis.com/google.rpc.ErrorInfo
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeAny(JsonFormat.java:1511)

Possible solution:
Add the message type in
https://github.com/googleapis/sdk-platform-java/blob/003b993f7ad7cae8ae8c101e0ff147e517dcd83e/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposer.java#L1279-L1286

Activity

  1. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Nov 10, 2023
  2. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Nov 13, 2023
  3. JoeWang1127 commented on Nov 13, 2023

    @JoeWang1127
    ContributorAuthor

    In the possible solution part, the types are added recursively in TypeRegistry.Builder.add() method.

    However, only two types serves as the "root" of this method, WaitRequest and WaitResponse, we need to understand the reason behind this before adding ErrorInfo into the registry.

  4. self-assigned this
    on Nov 20, 2023
  5. blakeli0 commented on Nov 21, 2023

    @blakeli0
    Contributor

    I'm afraid this issue is more complicated than we expected. The new Showcase feature tests that we can deserialize an Any field to a concrete field in ErrorInfo, which is only used by the Error Details feature, and it was deferred last year. See b/260671246 for details. In short, we can not support this test for HttpJson stubs until Error Details feature is implemented for REGAPIC.

    In the mean time, I think it's still worth it to add a showcase test for gRPC.

  6. removed their assignment
    on Nov 21, 2023
  7. diegomarquezp commented on Feb 7, 2024

    @diegomarquezp
    Contributor

    we can not support this test for HttpJson stubs until Error Details feature is implemented for REGAPIC

    I'll be demoting this to p3

  8. added
    priority: p3Desirable enhancement or fix. May not be included in next release.
    and removed
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Feb 7, 2024
  9. blakeli0 commented on Aug 9, 2024

    @blakeli0
    Contributor

    Verified that adding ErrorInfo to the type registry should fix this issue, see googleapis/sdk-platform-java#3093. However, we need to figure out where exact to add the additional types, either in Gax or generated layers.

    Theoretically this issue can be tackled individually, but it will likely be resolved if the actionable ErrorDetails project is implemented for httpjson. Hence keeping this as a P3.

  10. baeminbo commented on Feb 13, 2025

    @baeminbo
    Contributor

    I reported a related issue at #12247. That issue is about a failure in parsing error status during server streaming calls. It has two underlying problems:

    1. HttpJsonClientCallImpl.consumeMessageFromStream() uses the TypeRegistry from HttpJsonCallOptions, ignoring the default registry in ProtoMessageResponseParser. If the TypeRegistry is null in HttpJsonCallOptions, a NullPointerException is thrown.
    2. DebugInfo is not added in TypeRegistry for HttpJson*Stub (this issue discussed here). This causes InvalidProtocolBufferException with "Cannot resolve type: type.googleapis.com/google.rpc.DebugInfo" even if the NPE issue is fixed.
  11. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    and removed
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Oct 17, 2025
  12. changed the title [-]Handle `google.rpc.ErrorInfo` in HttpJson*Stub class[/-] [+][sdk-platform-java] Handle `google.rpc.ErrorInfo` in HttpJson*Stub class[/+] on Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions