alirezashamsabad opened a new pull request, #13811: URL: https://github.com/apache/apisix/pull/13811
### Description `id_schema` allows a resource id to be either a string or an integer, and the `grpc-transcode` docs type `proto_id` as `string/integer`. But `create_proto_obj` compares the configured `proto_id` against the stored id with `==`, and in Lua `1 == "1"` is false. The admin API stores the id as a string, so any Route configuring `"proto_id": 1` fails to resolve its proto: ``` proto load error: failed to find proto by id: 1 ``` Reproducer against master: two Routes over the same proto, one with the id as a string and one as an integer. ```shell curl "http://127.0.0.1:9180/apisix/admin/routes/1" -H "X-API-KEY: $admin_key" -X PUT -d ' { "uri": "/str", "plugins": { "grpc-transcode": { "proto_id": "1", "service": "helloworld.Greeter", "method": "SayHello" } }, "upstream": { "scheme": "grpc", "type": "roundrobin", "nodes": { "127.0.0.1:10051": 1 } } }' curl "http://127.0.0.1:9180/apisix/admin/routes/2" -H "X-API-KEY: $admin_key" -X PUT -d ' { "uri": "/int", "plugins": { "grpc-transcode": { "proto_id": 1, "service": "helloworld.Greeter", "method": "SayHello" } }, "upstream": { "scheme": "grpc", "type": "roundrobin", "nodes": { "127.0.0.1:10051": 1 } } }' ``` `/str` transcodes, `/int` returns an error and logs `failed to find proto by id: 1`. This compares both sides as strings, matching how `graphql-proxy-cache` and `upstream.lua` already normalize ids. #### Which issue(s) this PR fixes: Fixes [#8952](https://github.com/apache/apisix/issues/8952), which was closed as stale without a fix. The report is still reproducible on master. ### Tests Two blocks added to `t/plugin/grpc-transcode.t`: a Route configured with an integer `proto_id`, and a request through it. Both fail without the change and pass with it. Developed with AI assistance; design decisions, review and testing are my own. ### Checklist - [x] I have explained the need for this PR and the problem it solves - [x] I have explained the changes or the new features added to this PR - [x] I have added tests corresponding to this change - [ ] I have updated the documentation to reflect this change (not needed: the docs already type `proto_id` as `string/integer`; this makes the code match them) - [x] I have verified that this change is backward compatible (If it is not backward compatible, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
