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

if the message has an optional field with a return value, the proto will attach a same name field with _ prefix. why? #2754

Open
wang-xiaowu opened this issue May 22, 2024 · 2 comments

Comments

@wang-xiaowu
Copy link

Problem description

if the message has an option field with a return value, the proto will attach a same name field with _ prefix. why?

Reproduction steps

  • message like this
message Res {
    uint32 code = 1;
    optional string msg = 2;
    string status = 3;
    optional string error = 4;
    optional uint32 count = 5;
}
  • server retun
    image

  • real result client got
    image

Environment

  • OS name, version and architecture: windows11
  • Node version : 16.15
  • Node installation method. binary
  • If applicable, compiler version [e.g. clang 3.8.0-2ubuntu4]
  • Package name and version: 1.10.8

Additional context

@murgatroid99
Copy link
Member

This is controlled by the message decoding code on the client. What protobuf implementation are you using on the client?

@wang-xiaowu
Copy link
Author

proto3 with @grpc/proto-loader.
this is protoLoaderOptions,

const protoLoaderOptions = {
  keepCase: true,
  longs: String,
  enums: String,
  defaults: true,
  oneofs: true,
};

@wang-xiaowu wang-xiaowu changed the title if the message has an option field with a return value, the proto will attach a same name field with _ prefix. why? if the message has an optional field with a return value, the proto will attach a same name field with _ prefix. why? May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants