Nitish Bhardwaj
Nitish Bhardwaj

Reputation: 1187

Invalid Protocol Buffer schema. Import "google/protobuf/any.proto" has not been loaded: GCP/Pub-Sub

I am new to GCP. I am trying to use Pub/Sub service with schema definition using protobuf.

Schema:

syntax = "proto3";

import "google/protobuf/any.proto";

message Endorsement {
  string endorserId=1;
  google.protobuf.Any data = 2;
  string signature=3;
  bool isVerified=4;
}

message TransactionPayload {
  string policyId =1;
  string txnId =2;
  repeated Endorsement endorsements=3;
}

Validation of this schema fails with an error

Invalid Protocol Buffer schema. Import "google/protobuf/any.proto" has not been loaded.

enter image description here

I need to use google.protobuf.Any, is there any other way to use/define this?

Upvotes: 7

Views: 2174

Answers (1)

Kamal Aboul-Hosn
Kamal Aboul-Hosn

Reputation: 17206

Currently, imports are not supported with Pub/Sub's schema support. You'd have to define the message type yourself in the definition for your message type. Note also that the current schema support only allows a single message top-message type to be defined, so you'd also have to embed the Endorsement definition inside the TransactionPayload definition.

Upvotes: 4

Related Questions