Repository navigation
fix: honor Binder behind an optional pointer - #198
Merged
mromaszewicz merged 1 commit intoNov 23, 2026
Merged
mromaszewicz merged 1 commit into
mromaszewicz merged 1 commit into
Conversation
BindStringToObject checks for Binder on the destination as passed. For an optional field that is a **T, which never implements Binder, so the type fell through to the built-in conversion for its kind. An integer type with a Bind method was parsed as a plain integer: its validation was skipped and any syntax of its own was refused. The same type bound through Bind as a required field or as a top-level optional parameter. Check again once the optional pointer has been dereferenced, so that a Binder has the same precedence in both cases. This changes the result for an optional property of an exploded form object whose type has a primitive kind and implements Binder: values which Bind rejects are now errors, values only Bind understands now bind, and a Bind which transforms its input now takes effect. Types without a Bind method are unaffected. types.Date binds the same values as before, though a malformed date now reports the error from Date.Bind. Part of oapi-codegen#196 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.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.
Part of #196 (2 of 2). This one is a behavior change; see below.
Problem
BindStringToObjectchecks forBinderon the destination as passed. For an optional field that is a**T, which never implementsBinder, so the type fell through to the built-in conversion for its kind andBindwas never called.With an integer type whose
Bindaccepts50%and rejects anything over 100:5050%150*Percent)Percent)*Percent)The last row skipped the type's validation and refused its syntax.
Fix
Check for
Binderagain once the optional pointer has been dereferenced, so it has the same precedence in both cases. After this change the last row matches the other two.Behavior change
Affects an optional property of an exploded form object (or any other caller passing a
**T) whose type implementsBinderand has a kind with a built-in conversion:Bindrejects but the primitive parser accepted are now errors (a 400 in generated servers);Bindunderstands now bind;Bindthat transforms its input now takes effect.Types without a
Bindmethod are unaffected.types.DateimplementsBinder, so an optional date property now goes throughDate.Bind: it accepts the same values as before, including the empty string, but a malformed date reports the parse error without the previouserror parsing '…' as dateprefix.Worth a line in the release notes.
The companion PR (fallback for types with no built-in conversion) is independent of this one and the two merge cleanly in either order.
🤖 Generated with Claude Code