Skip to content

fix(templates/client): correctly nil check query parameters#2237

Merged
jamietanna merged 1 commit intomainfrom
fix/prefer-optional-bind
Feb 24, 2026
Merged

fix(templates/client): correctly nil check query parameters#2237
jamietanna merged 1 commit intomainfrom
fix/prefer-optional-bind

Conversation

@jamietanna
Copy link
Member

As a fix similar to c4ba545, we had
cases where the global prefer-skip-optional-pointer could lead to not
nil checking when we should have been.

The previous behaviour would lead to incorrectly converting i.e.
user_ids=nil to user_ids[]=, which is not correct.

To do this, we can add the same helper functions that we have elsewhere.

@jamietanna jamietanna requested a review from a team as a code owner February 24, 2026 13:55
@greptile-apps
Copy link

greptile-apps bot commented Feb 24, 2026

Required label not found on this PR.

As a fix similar to c4ba545, we had
cases where the global `prefer-skip-optional-pointer` could lead to not
nil checking when we should have been.

The previous behaviour would lead to incorrectly converting i.e.
`user_ids=nil` to `user_ids[]=`, which is not correct.

To do this, we can add the same helper functions that we have elsewhere.
@jamietanna jamietanna merged commit 918ff57 into main Feb 24, 2026
52 checks passed
@jamietanna jamietanna deleted the fix/prefer-optional-bind branch February 24, 2026 15:11
@jamietanna jamietanna added the bug Something isn't working label Feb 27, 2026
mromaszewicz added a commit to mromaszewicz/oapi-codegen that referenced this pull request Feb 28, 2026
…late (oapi-codegen#2238)

PR oapi-codegen#2237 fixed query parameters to use RequiresNilCheck instead of
HasOptionalPointer for nil-check guards, but the same bug remained in
the header and cookie parameter sections of client.tmpl. This caused
optional array params (e.g. []string) to be sent even when nil, because
prefer-skip-optional-pointer removes the pointer wrapper and
HasOptionalPointer returns false, skipping the nil check entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mromaszewicz added a commit to mromaszewicz/oapi-codegen that referenced this pull request Feb 28, 2026
PR oapi-codegen#2237 fixed query parameters to use RequiresNilCheck instead of
HasOptionalPointer for nil-check guards, but the same bug remained in
the header and cookie parameter sections of client.tmpl. This caused
optional array params (e.g. []string) to be sent even when nil, because
prefer-skip-optional-pointer removes the pointer wrapper and
HasOptionalPointer returns false, skipping the nil check entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mromaszewicz added a commit that referenced this pull request Mar 2, 2026
PR #2237 fixed query parameters to use RequiresNilCheck instead of
HasOptionalPointer for nil-check guards, but the same bug remained in
the header and cookie parameter sections of client.tmpl. This caused
optional array params (e.g. []string) to be sent even when nil, because
prefer-skip-optional-pointer removes the pointer wrapper and
HasOptionalPointer returns false, skipping the nil check entirely.

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

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants