Repository navigation
fix(datamodel/low): make NodeLines nil-safe to stop panics on skipped external refs - #707
Open
swayam5342 wants to merge 1 commit into
Open
swayam5342 wants to merge 1 commit into
swayam5342 wants to merge 1 commit into
Conversation
… external refs Fixes pb33f#705
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #707 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 315 315
Lines 39758 39764 +6
=========================================
+ Hits 39758 39764 +6
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 #705.
With
SkipExternalRefResolutionenabled, an external$refused as a map entry (a media type, header, link, example, encoding, callback or webhook) is replaced inExtractMapExtensionsby a placeholder that is never built, so itsNodesstore isnil. The parent'sBuildthen callsv.Value.Nodes.Store(...)on it, which panics in(*NodeLines).write. The panic happens on aTranslateSliceParallelgoroutine, so callers can't recover it and the process exits.This affects 12 of the 13
v.Value.Nodes.Storeloops indatamodel/low/v3. With resolution not skipped, the same documents return an error, as before. The bug has been present sinceSkipExternalRefResolutionwas added in 1b522c2 (first released in v0.33.4).Change
*NodeLinesis now safe to use through a nil pointer:write(and soStoreandadd) does nothing,Loadreports not-found, andRangevisits nothing.NodeMap.GetNodesandGetNodeLinesalready accept a nil store, so this extends the same contract to the rest of the type and fixes every call site in one place. Objects that were built have a non-nil store, so their behavior doesn't change.Tests
TestNodeLines_NilReceiver: the nil-store contract.TestSkipExternalRefResolution_ExternalRefMapEntriesDoNotPanic: one document per affected map, built withSkipExternalRefResolution: true. Without this change the test binary crashes; with it, all 12 cases build without error.go test ./...on Windows (go1.27.0): 33 packages pass.TestRolodex_SimpleTest_OneDocandTestSpecIndex_BurgerShopMixedRef(index), andFuzzAppendJSONStringseed #5 (json), fail with identical output on unmodifiedmainon the same machine, so they're unrelated to this change. They look like Windows-specific byte counts.Possible follow-up
Kept out of this PR because it changes behavior library-wide: recovering panics inside the
TranslateSliceParallelworkers and returning them as errors, so a future bug of this kind can't take down the host process.