fix(http): honor the Name on [FromRoute] for endpoint method parameters#3356
Merged
jeremydmiller merged 2 commits intoJul 10, 2026
Conversation
added 2 commits
July 10, 2026 17:39
[FromRoute(Name = "my-id")] was only read by AsParametersBindingFrame. On a plain endpoint method parameter the attribute name was ignored: matching fell through to the parameter name, missed the route token, and QueryStringParameterStrategy silently bound the argument from the query string instead. A kebab-cased route token could not be bound at all, since it is not a legal C# identifier. RouteParameterStrategy now resolves the route argument by the attribute name when one is given, and throws when no such route argument exists rather than binding from somewhere else. Route variables are also now looked up by their route key rather than by their sanitized C# usage, so a route token containing '-', '.' or '/' de-duplicates correctly and carries its real type onto the generated OpenAPI parameter.
This was referenced Jul 10, 2026
This was referenced Jul 14, 2026
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.
Problem
[FromRoute(Name = "...")]is only read insideAsParametersBindingFrame. On a plain endpoint method parameter the attribute'sNameis ignored —RouteParameterStrategymatches onParameterInfo.Nameonly:So for
/journeys/{journey-id}/legs+[FromRoute(Name = "journey-id")] int journeyId:RouteParameterStrategymisses ("journeyId" != "journey-id")QueryStringParameterStrategy, which claims any parseable typehttpContext.Request.Query["journeyId"], so the argument binds to0Silent wrong binding, no exception. And a kebab-cased route token can't be bound by convention at all, because
journey-idisn't a legal C# identifier — so the attribute was the only way to reach it.Fix
RouteParameterStrategy.TryMatchnow resolves the route argument by the attribute'sNamewhen one is supplied, and throws when no such route argument exists rather than letting the parameter be quietly bound from somewhere else — mirroring the existing[AsParameters]behaviour.Two related lookups matched route variables on
Variable.Usage(the sanitized C# identifier,journey_id) instead ofHttpElementVariable.Name(the route key,journey-id):HttpChain.FindRouteVariable(Type, string)— the de-dupe check never hit for a sanitized name, so two members bound to the same route token emitted the same local twice (CS0128).HttpChain.buildParameterDescription— the OpenAPI parameter lost its real type and fell back tostringunless the route carried an inline constraint.Both now compare against the route key.
Tests
named_route_parameter_bindingcovers a kebab-cased route token bound to anintmethod parameter, to astringmethod parameter, and through[AsParameters]alongside a[FromBody]member. The two direct-parameter cases fail onmain; all three pass with the fix.Full
Wolverine.Http.Testsgreen (811 passed, 10 skipped), anddotnet build wolverine.slnx -c Releasesucceeds.Repro
The second commit adds
repro/kebab-cased-route-parameter.cs, a .NET 10 file-based app that boots a real Wolverine HTTP host, exercises both shapes over HTTP, and exits non-zero on failure. It's self-contained (dotnet run repro/kebab-cased-route-parameter.cs) and needs no test framework.With the fix:
Against
main:Happy to drop that commit if a top-level
repro/directory isn't a convention you want — the fix and the xUnit coverage stand on their own without it.