Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gapic-generator-java: LRO parsing can match wrong response or metadata type #1707

Closed
emmileaf opened this issue May 24, 2023 · 0 comments · Fixed by #1726
Closed

gapic-generator-java: LRO parsing can match wrong response or metadata type #1707

emmileaf opened this issue May 24, 2023 · 0 comments · Fixed by #1726
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@emmileaf
Copy link
Contributor

emmileaf commented May 24, 2023

This issue happens in Parser.parseLro(): if only shortname is provided, and has ambiguity with message types from other protos, the parser currently naively matches on first encountered type, without throwing exception or indicating conflict.

// The messageTypes map keys to the Java fully-qualified name.
for (Map.Entry<String, Message> messageEntry : messageTypes.entrySet()) {
String messageKey = messageEntry.getKey();
int messageLastDotIndex = messageEntry.getKey().lastIndexOf('.');
String messageShortName =
messageLastDotIndex >= 0 ? messageKey.substring(messageLastDotIndex + 1) : messageKey;
if (responseMessage == null) {
if (isResponseTypeNameShortOnly && responseTypeName.equals(messageShortName)) {
responseMessage = messageEntry.getValue();

Example proto to reproduce:

  • Annotation type is ambiguous with DescriptorProtos.GeneratedCodeInfo.Annotation
  • Location type is ambiguous with DescriptorProtos.SourceCodeInfo.Location
service TestService {
 ...
  rpc annotationTest(Request) returns (google.longrunning.Operation) {
    option (google.longrunning.operation_info) = {
      response_type: "Annotation" 
      metadata_type: "Location"
    };
  }
}

message Annotation {
  string name = 1;
}

message Location {
  string name = 1;
}
@emmileaf emmileaf added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels May 24, 2023
@emmileaf emmileaf self-assigned this May 24, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
1 participant