Skip to content

Support gRPC-JSON transcoder - #9905

Open
nfarhadian wants to merge 4 commits into
envoyproxy:mainfrom
nfarhadian:grpc-json-hrf
Open

Support gRPC-JSON transcoder#9905
nfarhadian wants to merge 4 commits into
envoyproxy:mainfrom
nfarhadian:grpc-json-hrf

Conversation

@nfarhadian

@nfarhadian nfarhadian commented Aug 31, 2026

Copy link
Copy Markdown

What this PR does / why we need it:

Adds grpcJSONTranscoder to HTTPRouteFilter, referenced from an HTTPRoute rule via extensionRef. REST/JSON clients can call a gRPC backend without a separate transcoding proxy.

The proto descriptor comes from a ConfigMap in the route's namespace and is parsed and validated at translation time, so a bad descriptor becomes a route condition (Accepted=False, UnsupportedValue) plus a 500, rather than a rejected listener. Descriptors must be built with protoc --include_imports.

The filter is emitted once per config on the HCM, disabled by default, and enabled per route through typedPerFilterConfig, so the descriptor is not copied onto every route. Listeners with no transcoder are byte-identical to before.

Rejected where it cannot work: a backendRef filter has no route table to enable it on, and a GRPCRoute only carries traffic that is already gRPC.

Worth reviewer attention:

  • matchIncomingRequestRoute defaults to false (Envoy's default), so the rewritten
    gRPC path is re-matched and needs a route. Documented, with the single-rule form
    shown first.

Which issue(s) this PR fixes:

Fixes #1776


PR Checklist

  • Authorship & ownership: Coding agents / AI assistants are welcome, but I have reviewed every change, understand how and why it works, can explain and maintain it, and take full responsibility for this PR. I have not submitted generated output I do not understand.
  • DCO: All commits are signed off (git commit -s). See DCO: Sign your work.
  • API agreed first: If this PR contains API changes (changes under /api), the API was discussed and agreed before the implementation. The API change can be in a separate PR, or in the same PR, but the API must be agreed before implementation. N/A if this PR does not contain API changes.
  • Required checks pass: make generate gen-check, make lint, and the unit-test/coverage build pass. (Flaky e2e failures are not considered breakages, but gen-check, lint, and coverage MUST pass.)
  • Tests added/updated: New/changed code is covered by appropriate tests. N/A if this PR does not contain code changes.
  • Docs: User-facing changes update the docs, either in this PR or a follow-up PR. N/A if this PR does not contain user-facing changes.
  • Release notes: For any non-trivial change, added a release-note fragment under release-notes/current/<section>/<pr-number>-<slug>.md (see release-notes/current/README.md for sections and naming). N/A if this PR does not contain non-trivial changes.
  • Generated files committed: Ran make gen-check and committed the result if API/helm charts/modules changed.
  • Scope & compatibility: The PR is reasonably scoped (no unrelated changes) and preserves backward compatibility, or any breaking change is called out above and documented in release-notes/current/breaking_changes/.
  • Codex review: Requested a Codex review and addressed all of its comments.
  • Copilot review: Requested a Copilot review and addressed all of its comments.

@netlify

netlify Bot commented Aug 31, 2026

Copy link
Copy Markdown

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit b284757
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a9dc088b730170008e3ff97
😎 Deploy Preview https://deploy-preview-9905--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nfarhadian
nfarhadian force-pushed the grpc-json-hrf branch 3 times, most recently from 67bd275 to f3d1aae Compare September 6, 2026 15:58
nfarhadian and others added 3 commits September 6, 2026 21:58
transformConfigMapData trims a cached ConfigMap's Data to cachedConfigMapKeys
plus its lexicographically first key. LocalObjectKeyReference.Key is named by
the SecurityPolicy, so no static allow-list can cover it and the policy was
rejected for a key the API server still holds.

Feeding referenced keys into the transform would race a ConfigMap cached and
trimmed before the policy referencing it exists, so this read uses the uncached
API reader instead. Offline it is the same client, which has no cache to bypass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Naeem Farhadian <n.f.azizi@gmail.com>
The offline loader only copied Data, so `egctl x translate` dropped any
binaryData entry. Descriptors created with `kubectl create configmap
--from-file` live there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Naeem Farhadian <n.f.azizi@gmail.com>
Extracted into addRouteFilterConfigMap so a second ValueRef on the same filter
can reuse the fetch, dedup and resourceTree append.

The error log gains a `field` key naming which ValueRef failed; DirectResponse
is otherwise unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Naeem Farhadian <n.f.azizi@gmail.com>
@nfarhadian
nfarhadian marked this pull request as ready for review September 6, 2026 18:40
@nfarhadian
nfarhadian requested a review from a team as a code owner September 6, 2026 18:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9bd921afc9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread api/v1alpha1/grpc_json_transcoder_types.go Outdated
Comment thread api/v1alpha1/grpc_json_transcoder_types.go Outdated
@nfarhadian

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c4aa792f3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +56 to +57
// When false (the default), a request carrying an unmappable parameter is rejected by
// the gateway with 415 and never reaches the backend.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Document unknown query failures as HTTP 400

The revised text provides fresh evidence beyond the prior comment by newly hard-coding status 415. An unmappable query parameter is reported by the transcoder as an invalid argument, which Envoy returns as 400 Bad Request; 415 denotes an unsupported media type. Publishing 415 in the API and generated CRD documentation will send users toward content-type debugging, so state 400 or omit the numeric status.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original wording was correct, it reaches the backend and since it does not have content-type backend responds with 415
Here is the envoy logic which passes the request:
https://github.com/envoyproxy/envoy/blob/v1.39.1/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc#L514-L521

Adds grpcJSONTranscoder to HTTPRouteFilter, referenced from an HTTPRoute rule
via extensionRef. The proto descriptor comes from a ConfigMap in the route's
namespace and is validated at translation time, so a bad descriptor becomes a
route condition instead of a rejected listener.

The filter is emitted once per config on the HCM, disabled by default, and
enabled per route through typedPerFilterConfig, so the descriptor is not copied
onto every route.

Rejected where it cannot work: a backendRef filter has no route table to enable
it on, and a GRPCRoute only carries traffic that is already gRPC. Both would
otherwise be dropped silently.

proto-descriptor joins the provider's cachedConfigMapKeys, or the informer
transform drops it from any ConfigMap carrying more than one data entry. That
transform also trims Data to its first key, so only a sole binaryData entry can
stand in for the named key; a sole Data entry would mean something different
in-cluster than it does to egctl.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Naeem Farhadian <n.f.azizi@gmail.com>
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.40249% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.36%. Comparing base (56518d2) to head (b284757).

Files with missing lines Patch % Lines
internal/provider/kubernetes/filters.go 16.66% 15 Missing ⚠️
internal/gatewayapi/grpc_json_transcoder.go 93.47% 9 Missing ⚠️
internal/provider/kubernetes/indexers.go 0.00% 9 Missing ⚠️
internal/xds/translator/grpc_json_transcoder.go 87.27% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9905      +/-   ##
==========================================
+ Coverage   81.34%   81.36%   +0.01%     
==========================================
  Files         264      266       +2     
  Lines       40967    41185     +218     
==========================================
+ Hits        33326    33511     +185     
- Misses       7640     7673      +33     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arkodg

arkodg commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

hey can the API be scoped to the fields needed for your use case ?
also can we add support for validateHTTPBindings

@nfarhadian

Copy link
Copy Markdown
Author

Currently we enable convert_grpc_status, always_print_primitive_fields in print options and also service list. But having other fields does not cost much.

I don't understand validateHTTPBindings you mentioned. Do you mean having request_validation_options in transcoder configuration or validating the descriptor bindings in runtime?

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.

Support gRPC-JSON transcoder

2 participants