hanzhenfang opened a new pull request, #14076: URL: https://github.com/apache/apisix/pull/14076
### Description A route with `grpc-transcode.proto_id: 1` cannot find a proto stored by the Admin API as `"1"`, although the schema and documentation allow integer IDs. Normalize the requested ID before the proto cache lookup and compare stored IDs as strings, so integer and string references resolve the same proto and share one cache entry. This continues @alirezashamsabad's fix in #13811, which remains open, unmerged and marked stale. The original diagnosis and string-normalization approach are credited to that PR. This replacement is based on current master (`cea64fbf`) to take over maintenance and add broader regression coverage; it does not imply the original implementation was rejected or that its author endorsed this replacement. Compared with #13811: - Normalize the request ID in `fetch`, before the LRU lookup, rather than only inside `create_proto_obj`. `1` and `"1"` now share the compiled proto cache; configuration-version invalidation is retained. - Keep stored-ID string normalization. Preserve distinct string IDs such as `"01"`; do not coerce IDs to numbers. - Add a separate test file instead of extending the already over-800-line `grpc-transcode.t`, following the contribution guide. - Cover real integer/string route requests, missing IDs, leading-zero IDs, and updates of an already-cached proto. After a schema update, both routes must decode the backend response using the new field name. - Clarify integer/string ID equivalence in both English and Chinese plugin documentation. #### Which issue(s) this PR fixes: Fixes #8952 (previously closed as stale without this fix). Related implementation: #13811. ### Validation Using current checkout sources with the Linux `apache/apisix:3.19.0-debian` runtime, an isolated etcd, and the repository's Go gRPC test server: - `prove -I/tmp/test-nginx/lib -I. t/plugin/grpc-transcode-proto-id.t`: 7 cases / 21 assertions pass. Before the fix, integer requests fail with `failed to find proto by id: 1`; string requests succeed. - `grpc-transcode-reload-bugfix.t`, `grpc-transcode2.t`, `grpc-transcode3.t`, and `grpc-transcode4.t` also pass. - The HUP-based `grpc-transcode.t` reports worker-events `failed to receive the header bytes: closed` during TEST 19. Re-running that existing test with the unmodified master `proto.lua` reproduces the same failure. This environment does not provide a clean full grpc-transcode suite result; the failure is not suppressed. - `luacheck -q apisix t/lib`: 0 warnings/errors in 406 files. - Changed-file `lj-releng`, repository test-style checks, and `git diff --check`: pass. - Full `make lint` is blocked by existing Unicode separator line-length errors in unchanged discovery files (Consul, Kubernetes, Nacos, among others). Those unrelated files are not changed here. The full APISIX service matrix was not run locally. Draft pending repository CI. ### 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 - [x] I have updated the documentation to reflect this change - [x] I have verified that this change is backward compatible (string IDs, distinct leading-zero IDs, missing IDs, and proto updates are covered) -- 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]
