fix: initialize operation reference so a failed sibling cannot cause a nil panic - #619
Open
SAY-5 wants to merge 1 commit into
Open
fix: initialize operation reference so a failed sibling cannot cause a nil panic#619SAY-5 wants to merge 1 commit into
SAY-5 wants to merge 1 commit into
Conversation
…a nil panic Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #616.
When one operation in a path item fails to build (for example a dangling
$refin a response schema), the sibling operations in that same path item are left as partially-built lowOperationstructs whose embedded*low.Referenceis still nil. CallingIsReference()on one of them then panics with a nil pointer dereference, so a single bad$refcan 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 inPathItem.Build(the sameo.reference = low.Reference{}; o.Reference = &o.referencepatternOperation.Buildalready 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.