Skip to content

Fix [FromQuery] array binding ignoring Name alias#2262

Merged
jeremydmiller merged 1 commit intomainfrom
fix/fromquery-array-binding-alias
Mar 5, 2026
Merged

Fix [FromQuery] array binding ignoring Name alias#2262
jeremydmiller merged 1 commit intomainfrom
fix/fromquery-array-binding-alias

Conversation

@jeremydmiller
Copy link
Member

Summary

  • When a record used [FromQuery(Name = "v")] string[] Values and was bound via [FromQuery], the generated code read from httpContext.Request.Query["Values"] instead of httpContext.Request.Query["v"]. The [AsParameters] path handled this correctly.
  • Root cause: HttpChain.TryFindOrCreateQuerystringValue(Type, string, string?) passed parameterName (C# name) instead of key (the alias) when constructing ParsedArrayQueryStringValue, ParsedCollectionQueryStringValue, and nullable type frames.
  • Added tests covering aliased arrays/collections for both [FromQuery] and [AsParameters] on records and settable properties.

Closes #2257

Test plan

  • All 512 Wolverine.Http.Tests pass (10 skipped, unchanged)
  • New tests verify aliased string arrays, int arrays, and enum lists via [FromQuery] on records
  • New tests verify parity between [FromQuery] and [AsParameters] for aliased arrays

🤖 Generated with Claude Code

…or parameters

The query string key for arrays, collections, and nullable types was using
the C# parameter name instead of the [FromQuery(Name = "...")] alias in
HttpChain.TryFindOrCreateQuerystringValue, causing a discrepancy with
[AsParameters] which handled aliases correctly.

Closes #2257

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Discrepancy between [FromQuery] and [AsParameters] for records when type is array

1 participant