Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

'Cannot find type for url' error for items of google.protobuf.Any type #41

Open
@pmirek

Description

@pmirek

Description

How Any type is handled, as I have issues to get it working.
I have offer_item, that is defined as

message OfferItem {
  google.protobuf.Any offer_item = 1;
}

But got errors related to finding class referenced from that item.

Message being sent:

grpcurl -plaintext -import-path ./protos -proto stub/offer/proto/OfferSvc.proto -d '
{
  "offer_id": "newoffer001",
  "ttl": { "seconds": 900 },
  "offer_to_add": {
    "offer_items": [
      {
        "offer_item": {
          "value": "newoffer001",
          "@type": "type.googleapis.com/google.protobuf.StringValue"
        }
      }
    ]
  }
}' localhost:50000 stub.offer.proto.OfferSvc/addOffer

From logs I got:

Message:
offer_id: "newoffer001"
ttl {
  seconds: 900
}
offer_to_add {
  offer_items {
    offer_item {
      type_url: "type.googleapis.com/google.protobuf.StringValue"
      value: "\n\032newoffer001"
    }
  }
}

And exception stack:

Caused by: com.google.protobuf.InvalidProtocolBufferException: Cannot find type for url: type.googleapis.com/google.protobuf.StringValue
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printAny(JsonFormat.java:886) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.access$1000(JsonFormat.java:714) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl$1.print(JsonFormat.java:787) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:766) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1263) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1128) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printField(JsonFormat.java:1052) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:1030) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:769) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1263) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1128) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printRepeatedFieldValue(JsonFormat.java:1066) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printField(JsonFormat.java:1050) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:1030) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:769) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1263) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1128) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printField(JsonFormat.java:1052) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:1030) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:769) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$Printer.appendTo(JsonFormat.java:372) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$Printer.print(JsonFormat.java:382) ~[protobuf-java-util-3.19.2.jar:na]

Though, when on container, it looks like StringValue is there:

/usr/src/java-code/build/classes# find . | grep String
./java/main/com/google/protobuf/StringValueOrBuilder.class
./java/main/com/google/protobuf/StringValue$1.class
./java/main/com/google/protobuf/StringValue$Builder.class
./java/main/com/google/protobuf/StringValue.class

Is this code issue, or I need to make corrections in test set or mock configuration to make it working?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions