fix transcoding query overwrites body/route parameters#66401
Open
DeagleGross wants to merge 3 commits intodotnet:mainfrom
Open
fix transcoding query overwrites body/route parameters#66401DeagleGross wants to merge 3 commits intodotnet:mainfrom
DeagleGross wants to merge 3 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes JSON transcoding request binding precedence so query string parameters cannot overwrite values already bound from route parameters or the HTTP body (including when query keys use JSON-name aliases).
Changes:
- Prevent query binding for body-bound fields using both proto field names and JSON names (including nested prefixes).
- Prevent query binding for route-bound fields when query keys match the route field’s JSON path alias.
- Add/extend tests and update the test proto to cover JSON-name alias scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Internal/JsonRequestHelpers.cs | Extends query-binding filter to block overwrites of body/route-bound fields via proto and JSON names. |
| src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Internal/CallHandlers/CallHandlerDescriptorInfo.cs | Precomputes a set of route parameter JSON paths for fast alias checks during query binding. |
| src/Grpc/JsonTranscoding/test/Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests/UnaryServerCallHandlerTests.cs | Adds regression tests ensuring query params (proto/JSON aliases) don’t overwrite route/body values. |
| src/Grpc/JsonTranscoding/test/Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests/Proto/transcoding.proto | Adds sub_data to exercise JSON-name prefix behavior for body-bound fields. |
…anscoding.Tests/UnaryServerCallHandlerTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed issue where in query parameter processing overwrites route or body-bound fields.