Skip to content

Handle google.rpc.ErrorInfo in HttpJson*Stub class #2237

@JoeWang1127

Description

@JoeWang1127

Followup on #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

for (Method method : service.methods()) {
if (method.hasLro()) {
TypeNode anyType = method.lro().responseType();
anyTypes.put(anyType.reference().fullName(), anyType);
anyType = method.lro().metadataType();
anyTypes.put(anyType.reference().fullName(), anyType);
}
}

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