Skip to content

fix(bind): preserve embedded scalar pointers during binding - #3244

Open
Twiink wants to merge 1 commit into
labstack:masterfrom
Twiink:fix/bind-embedded-scalar-20261122
Open

Twiink wants to merge 1 commit into
labstack:masterfrom
Twiink:fix/bind-embedded-scalar-20261122

Conversation

@Twiink

@Twiink Twiink commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

An endpoint using an initialized anonymous scalar pointer, such as struct { *Identifier query:"id" }, panics while binding ?id=42. The binder dereferences every anonymous pointer before passing the field to helpers that still expect its declared pointer kind, so reflect.Value.IsNil is called on an integer.

Only dereference anonymous pointers to structs at the recursion boundary. Embedded scalar pointers now follow the existing pointer binding path. The regression uses Context.Bind; an embedded scalar value is included as a passing control. Existing anonymous-struct and nil-pointer tests remain intact.

Validation:

  • Regression panics on the unchanged production code and passes after the fix.
  • go test -run TestBind -count=1 . passed.
  • go test -race -count=1 ./... passed (proxy environment removed for local-server tests).
  • go vet ./..., gofmt, and git diff --check passed.

AI assistance: OpenAI Codex prepared and reviewed the change and executed these checks under the account owner's authorization.

Summary by CodeRabbit

  • Bug Fixes
    • Improved query parameter binding for embedded scalar fields, including both pointer and value forms.
    • Anonymous pointer fields that do not point to structs are no longer treated as nested structs during binding.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Embedded scalar binding

Layer / File(s) Summary
Anonymous pointer dereferencing and scalar binding tests
bind.go, bind_embedded_scalar_test.go
Anonymous pointer dereferencing is limited to pointers to structs. Tests bind id=42 into embedded *EmbeddedIdentifier and EmbeddedIdentifier fields.

Suggested reviewers: kumapower17, vishr

Change: Bug fix

Merge Risk: Minimal · up to e8556

This fixes a panic when binding a query parameter into an embedded scalar pointer. Embedded struct pointers keep their existing behavior. No merge-blocking risk was found.

Security architecture risk: Minimal · up to e8556

This is a localized binding correction. Embedded scalar pointers retain their pointer type until existing conversion helpers process them, while field-selection rules and request-source ordering remain unchanged. No introduced or worsened architecture-level security risk was established.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e900ebf2-ec0a-4900-aa3d-4b1b8e8553ba
Commits

Reviewing files that changed from the base of the PR and between 59aacdd and e8556d7.

Files selected for processing: 2

  • bind.go
  • bind_embedded_scalar_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.23%. Comparing base (dcb05f0) to head (e8556d7).
⚠️ Report is 64 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3244      +/-   ##
==========================================
+ Coverage   93.34%   96.23%   +2.88%     
==========================================
  Files          43       46       +3     
  Lines        4735     4430     -305     
==========================================
- Hits         4420     4263     -157     
+ Misses        192      167      -25     
+ Partials      123        0     -123     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant