-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
bug: GRPC transcode can't work with protobuf.Struct #8655
Comments
@gaoxingliang
syntax = "proto3";
package test;
//import "protobuf/src/google/protobuf/struct.proto";
//copied from struct.proto
option cc_enable_arenas = true;
option go_package = "google.golang.org/protobuf/types/known/structpb";
option java_package = "com.google.protobuf";
option java_outer_classname = "StructProto";
option java_multiple_files = true;
...
message RawRequest {
//google.protobuf.Struct reqdata = 1;
Struct reqdata = 1;
string type = 2;
string serviceurl = 3;
string source = 4;
int32 page = 5;
int32 size = 6;
}
local pb = require "pb"
local protoc = require "protoc"
local cjson = require"cjson"
assert(protoc:loadfile("test_struct.proto"))
local data = [[
{
"type":"7",
"serviceurl" :"xxxx",
"reqdata" :{
"fields": {
"name": {"number_value":3},
"key": {"string_value":"yyyy"}
}
},
"source":"3"
}
]]
local tbl = cjson.decode(data)
print(cjson.encode(tbl))
local data = pb.encode("test.RawRequest", tbl)
local decoded = pb.decode("test.RawRequest", data)
print(cjson.encode(decoded)) $ luajit test_struct.lua
{"source":"3","reqdata":{"fields":{"name":{"number_value":3},"key":{"string_value":"yyyy"}}},"serviceurl":"xxxx","type":"7"}
{"reqdata":{"fields":{"name":{"number_value":3,"kind":"number_value"},"key":{"string_value":"yyyy","kind":"string_value"}}},"serviceurl":"xxxx","source":"3","page":0,"size":0,"type":"7"} |
@kingluo I checked the page: |
https://github.com/starwing/lua-protobuf/blob/master/test.lua#L657
https://github.com/starwing/lua-protobuf/blob/master/test.lua#L719 If you paste the definitions into one file without importing, the {
"reqdata":{
"fields":{
"name":{
"number_value":3,
"kind":"number_value"
},
"key":{
"string_value":"yyyy",
"kind":"string_value"
}
}
},
"serviceurl":"xxxx",
"source":"3",
"page":0,
"size":0,
"type":"7"
} |
@gaoxingliang I confirm it's a bug of grpc-transcode plugin. Here is the bugfix (I will submit PR later): Here is the test: |
Current Behavior
Problem
The inner struct object has not been parsed correctly. and is empty when using grpc-transcode plugin.
details
I have a grpc serivce with has below definition:
and I try to send a post request in postman with below request args:
and When I checking the logs, I found the reqdata object is empty (not null).
Expected Behavior
The struct object should has data.
Error Logs
No response
Steps to Reproduce
Environment
apisix:3.0.0
The text was updated successfully, but these errors were encountered: