Skip to content

fix(grpc-transcode): normalize integer proto references before caching - #14076

Closed
hanzhenfang wants to merge 1 commit into
apache:masterfrom
hanzhenfang:codex/fix-grpc-integer-proto-id
Closed

hanzhenfang wants to merge 1 commit into
apache:masterfrom
hanzhenfang:codex/fix-grpc-integer-proto-id

Conversation

@hanzhenfang

@hanzhenfang hanzhenfang commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (string IDs, distinct leading-zero IDs, missing IDs, and proto updates are covered)

Continue the integer proto ID fix proposed in apache#13811 with shared cache keys and regression coverage for ID types and schema updates.

Co-authored-by: alirezashamsabad <khajeshamsabad@outlook.com>
@hanzhenfang
hanzhenfang marked this pull request as ready for review October 23, 2026 12:35
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 this pull request may close these issues.

bug: failed to find proto by id in grpc-transcode plugin

1 participant