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

http json params to grpc service have discarded some params when using grpc transcode #5591

Closed
xiaokunliu opened this issue Nov 23, 2021 · 7 comments · Fixed by #7231
Closed

Comments

@xiaokunliu
Copy link

Issue description

http json params to grpc service have discarded some params when using grpc transcode, this is the curl :

curl --location --request POST 'http://apisix-gateway:9080/modelConfig/updateModelMessage'
--header 'Content-Type: application/json'
--data-raw '{"type":"lightGBM","joinTableList":[{"keyCol":"user_id","keyColInCombineTable":"user_id","table":{"conditions":[],"database":"dm","tableName":"dm_home_page_user_features"}},{"keyCol":"host_id","keyColInCombineTable":"host_id","table":{"conditions":[],"database":"dm","tableName":"dm_home_page_host_features"}}],"modelId":231,"trainDayDiff":1,"partitionArrange":[20211014,20211109],"name":"model12_copy","combineTable":{"conditions":[{"col":"ct","value":"click","op":"in_str"}],"database":"dm","tableName":"dm_feedctr_explose_click_sample_uid_ddi"}}
'

grpc service could not received the joinTableList, it is empty

Environment

  • apisix version (cmd: apisix version):
  • OS (cmd: uname -a):
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V):
  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API):
  • apisix-dashboard version, if have:
  • the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
  • luarocks version, if the issue is about installation (cmd: luarocks --version):
@tokers
Copy link
Contributor

tokers commented Nov 23, 2021

@xiaokunliu Please provide more details like your APISIX version, the Route and Upstream objects you created, and if possible, providing us the gRPC IDL.

@xiaokunliu
Copy link
Author

xiaokunliu commented Nov 24, 2021

ok, my problem is in my IDL, the repeated type filed could not using json array to transfer grpc repeated type,like example as follow:

syntax = "proto3";
package api;
service UserService {
rpc UpdateUserById(UpdateUserByIdRequest) returns (UpdateUserByIdResult);

message GetUserByIdResult {
sint64 uid = 1;
User user = 2;
}

message User {
string name = 1;
string email = 2;
// address
repeated UserAddress addresses = 3;
// profile
UserProfile userProfile = 4;
repeated sint64 tags = 5;
repeated string hobbies = 6;
}

message UserProfile {
sint64 uid = 1;
string loginName = 2;
string password = 3;
sint64 balances = 4;
}

message UserAddress {
string province = 1;
string city = 2;
string street = 3;
string detail = 4;
}
}

// the address could not get the value from http json array. and this is my curl request
curl --location --request PUT 'http://apisix-gateway:19080/user/UpdateUserById'
--header 'Content-Type: application/json'
--data-raw '{
"uid": 1111,
"user": {
"name": "uname",
"email": "uemail",
"addresses": [
{
"province": "guangdong",
"city": "guangzhou",
"street": "haizhu",
"detail": "pazhou"
}
],
"userProfile": {
"uid": "1111",
"loginName": "user",
"password": "user",
"balances": 100
},
"tags": [1,2,3],
"hobbies": ["footboall"]
}
}'

@xiaokunliu
Copy link
Author

apisix version : apache/apisix:2.10.0-alpine

@tokers
Copy link
Contributor

tokers commented Nov 24, 2021

So it's OK to pass it to the backend gRPC server if the APISIX proxy is skipped?

@xiaokunliu
Copy link
Author

xiaokunliu commented Nov 25, 2021

yes, others could pass, but address couldnt recieved, this is my backend grpc server log:

{"lv":"info","ts":1637747510,"caller":"grpcserver/users.go:63","msg":"UpdateUserById,uid=1111,user=name:"uname" email:"uemail" userProfile:<uid:1111 loginName:"user" password:"user" balances:100 > tags:1 tags:2 tags:3 hobbies:"footboall" hobbies:"basketball" "}

@jade-sun-1111
Copy link

I also encountered this problem. array of custom objects is lost

@jade-sun-1111
Copy link

@xiaokunliu code bug
lua table[name] can't convert array object
图片

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants