Pub/sub schema validation fails for Import "google/protobuf/any.proto" has not been loaded

839 views
Skip to first unread message

nitish bhardwaj

unread,
Jul 12, 2021, 12:38:32 PM7/12/21
to pubsub-discuss

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.

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


Ismail (Cloud Platform Support)

unread,
Jul 13, 2021, 10:24:22 AM7/13/21
to pubsub-discuss
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. 

As clarified on this Stack thread
Reply all
Reply to author
Forward
0 new messages