Skip to content

fix: initialize operation reference so a failed sibling cannot cause a nil panic - #619

Open
SAY-5 wants to merge 1 commit into
pb33f:mainfrom
SAY-5:fix-nil-reference-partial-operation
Open

fix: initialize operation reference so a failed sibling cannot cause a nil panic#619
SAY-5 wants to merge 1 commit into
pb33f:mainfrom
SAY-5:fix-nil-reference-partial-operation

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 23, 2026

Copy link
Copy Markdown

Fixes #616.

When one operation in a path item fails to build (for example a dangling $ref in a response schema), the sibling operations in that same path item are left as partially-built low Operation structs whose embedded *low.Reference is still nil. Calling IsReference() on one of them then panics with a nil pointer dereference, so a single bad $ref can take down anything that walks the returned model.

The embedded reference was only assigned inside Operation.Build, which never runs for the siblings when the parallel build aborts. This initializes it during the superficial build phase in PathItem.Build (the same o.reference = low.Reference{}; o.Reference = &o.reference pattern Operation.Build already uses), for both standard and additional operations, so the returned model is safe to inspect even when a build error is returned alongside it.

Added a regression test that reproduces the panic from the issue.

…a nil panic

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.78%. Comparing base (ca6ca73) to head (e45516a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #619   +/-   ##
=======================================
  Coverage   99.78%   99.78%           
=======================================
  Files         283      283           
  Lines       34456    34460    +4     
=======================================
+ Hits        34382    34386    +4     
  Misses         46       46           
  Partials       28       28           
Flag Coverage Δ
unittests 99.78% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

BuildV3Model returns a partially-built model that panics on public API

1 participant