What I am passing in
const params = {"Coffee":{"menuItemID":"1"} };
Proto
message MenuNumberOrNameRequest {
oneof Coffee {
string menuItem = 1;
uint32 menuItemID = 2;
}
}
The Result
✗ Exception raised “GoError: unable to serialise request object to protocol buffer: proto: (line 1:2): unknown field “Coffee””
Error Explanation
GoError: unable to serialise request object to protocol buffer: proto: (line 1:2): unknown field “Coffee”
Hi @Jamie
Thanks for reporting the issue. Can you try:
const params = {"menuItemID":"1"};
And let us know if that works? Discussing this with @ned the suspicion is that oneof
is not quite a sub-message field: protocol buffers - What is the expected JSON serialization of 'oneof' protobuf field? - Stack Overflow. Some implementations might choose a flat representation.
Do let us know either way. If this is the solution, we would definitely add this to the documentation to help other users. If not, we’ll keep digging.
Cheers!
That’s the ticket, its a shame the are different using different languages. I lifted this json format straight from a go project.
1 Like
Hi @Jamie ,
Thanks for getting back. We believe it’s good to document this behavior, so we’ve opened an issue to take care of it: Document the mapping of oneof with gRPC · Issue #1038 · grafana/k6-docs · GitHub
And many thanks for bringing this to our attention.
Cheers!
Do we have an update with this issue? I am getting similar issue with oneof Grpc as well. What is the best way to go around this
Hey i got it to work. you just need to submit one of the inner objects. So in my example it would be:
const params = {“menuItemID”:“1”};
or
const params = {“menuItem”:“Sugar”};
instead off:
const params = {“Coffee”:{“menuItemID”:“1”} };
1 Like