#Can't send google.protobuf.Value via gRPC payload

3 messages · Page 1 of 1 (latest)

slate gorge
#

I have a bug:

I have a gRPC service

syntax = "proto3";

import "google/protobuf/struct.proto";

service SharedDomainsEventsService {
    rpc HandleEvent (Event) returns (Event) {}
}

message Event {
    string name = 1;
    google.protobuf.Struct data = 2;
    string correlationId = 3;
}

And the following payload being sent by the client:

const event: Event = {
      name: 'Workflow',
      correlationId: '48f60676-c03d-477d-a20f-c42e05086350',
      data: { hello: 'world' },
    };

The message is received by the gRPC server, however the data parameter is empty, on the logs of the gRPC server it shows:

[Nest] 275137 - 09/07/2024, 9:34:30 PM DEBUG [SharedDomainsService] handleEvent called.
Input: {"name":"Workflow","data":{},"correlationId":"48f60676-c03d-477d-a20f-c42e05086350"}

I have tried manually importing the Struct from the google/protobuf/struct.ts file generated by protoc-gen-ts_proto and wrapping the data in this way:

    const event: Event = {
      name: workflow.name,
      correlationId: workflow.correlationId,
      data: Struct.wrap({
        kind: 'structValue',
        structValue: {
          fields: {
            hello: { kind: 'stringValue', stringValue: 'world' },
          },
        },
      }),
    };

No luck 😦
Please help
😿

slate gorge
flat cipher
#

Was facing the very same issue. So I went ahead with the map ' map<string, string>' and converted down all the values to strings using stringify method