v2.39.1
Overview
A patch release: correctness fixes for resolvers, validation, and response handling, plus a dependency refresh.
Response Status Visible to Middleware Again
WithContext context propagation in v2.39.0 copied the response status by value, so middleware that called WithContext and then read Status() after next() always saw 0 instead of the status the handler set, breaking access logging and telemetry. The status is now shared by every context copy across all adapters, restoring the pre-2.39 invariant while keeping context propagation intact. (#1081)
Resolvers & Defaults in Arrays and Maps
- Nested resolvers now run for fixed-size arrays (
[2]Item), not just slices (#1076) - A resolver on a named collection type (e.g.
type Coords [2]float64) no longer panics, and is no longer conflated with a resolver on its element type, which previously ran the element's resolver twice and the collection's never (#1082) - Values reached through a map are now written back after being walked, so applying a default no longer panics with
reflect: reflect.Value.Set using unaddressable valueand resolver mutations are no longer silently discarded (#1082)
Stricter email and uri Formats
Validation for two string formats is tighter, so payloads that previously passed may now return 422:
email/idn-emailaccept an addr-spec only; full mailbox forms with a display name (Name <user@example.com>) are rejecteduri/irirequire an absolute URI with a non-empty scheme, while relative references remain valid underuri-reference/iri-reference(#1068)
Validation Robustness
- An unresolvable schema
$refduringValidatenow reportsexpected schema $ref to resolve: ...instead of panicking on a nil dereference, covering discriminators andmap[string]any/map[any]anyvalues (#1065) - Named numeric slice parameters (e.g.
type IDs []int64) are built with their declared element type and validated with item, length, and uniqueness constraints intact (#1074)
Other Fixes
- Resolver errors that wrap a
HeadersErrornow contribute their headers to the response, matching the handler error path (#1070) - A nil interface response body no longer panics in the schema link transformer (#1072)
- Dependencies updated (#1066)
What's Changed
- fix: do not panic on unresolved schema $ref during Validate by @baiyuxi930826 in #1065
- chore: update dependencies by @wolveix in #1066
- fix: tighten format email and uri validation by @baiyuxi930826 in #1068
- fix: preserve wrapped resolver error metadata by @ggmolly in #1070
- fix: handle nil interface response bodies by @ggmolly in #1072
- fix: parse named numeric slice parameters by @ggmolly in #1074
- fix: share response status across WithContext copies by @wolveix in #1081
- fix: run nested resolvers in fixed arrays by @ggmolly in #1076
- fix: distinguish collection and element matches when walking input by @wolveix in #1082
New Contributors
- @baiyuxi930826 made their first contribution in #1065
- @ggmolly made their first contribution in #1070
Full Changelog: v2.39.0...v2.39.1