Draft
Fix package-level mutable slice/map reassignment in virtual_fs.go and actionpins/data.go#53896
Conversation
6 tasks
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Cleanup package-level mutable state in LintMonster
Fix package-level mutable slice/map reassignment in virtual_fs.go and actionpins/data.go
Aug 19, 2026
Contributor
|
Hey The refactoring is well-focused:
The changes preserve public APIs and behavior while eliminating the data-race hazards flagged by the linter. This looks ready for review!
|
Contributor
|
Triage: category= Small, contained bug fix (4 files, 46+/30-) with lgtm label. Undraft to trigger CI, then group with similar low-risk fixes for review.
|
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.
LintMonster flagged 5 findings where package-level slice/map variables were mutated via wholesale reassignment, risking shared-state leakage and data races:
builtinVirtualFilesinpkg/parser/virtual_fs.go, andcachedActionPins,cachedActionPinsByRepo,cachedContainerPinsinpkg/actionpins/data.go.pkg/parser/virtual_fs.gobuiltinVirtualFileschanged frommap[string][]byteto*map[string][]byte. Registration still builds a fresh copy-on-write snapshot, but now swaps the pointer instead of reassigning the map itself, so the package-level variable is never mutated in place.BuiltinVirtualFileExists,readFileFunc, wasm build) dereference the pointer; existingsync.RWMutexguarding is unchanged.pkg/actionpins/data.goactionPinsCachestruct bundlingpins,byRepo, andcontainers.*actionPinsCachepointer (cachedPins), populated exactly once inside the existingsync.Once.getActionPins(),GetActionPinsByRepo(), andGetContainerPin()now read through agetCachedActionPins()accessor instead of touching separate globals.Public APIs and behavior are unchanged — this is purely an internal storage-representation change to eliminate the reassignment pattern the linter flags.