fix: change const to let for policy reassignment in applyPreset#133
Closed
WuKongAI-CMU wants to merge 1 commit intoNVIDIA:mainfrom
Closed
fix: change const to let for policy reassignment in applyPreset#133WuKongAI-CMU wants to merge 1 commit intoNVIDIA:mainfrom
WuKongAI-CMU wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
applyPreset() crashes with "Assignment to constant variable" when a sandbox has a policy without a network_policies section. Change the declaration from const to let so the fallback path can prepend the version field. Also export extractPresetEntries and parseCurrentPolicy for testing and add 9 unit tests covering all three pure helpers. Signed-off-by: Peter Tam <nickthetam@gmail.com> Signed-off-by: peteryuqin <peter.yuqin@gmail.com>
5 tasks
Contributor
Author
|
Closing to reduce my open PR count below the repo policy limit and refocus on a smaller set of higher-signal changes. I can revive this branch later if it becomes the right path again. |
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.
Summary
TypeError: Assignment to constant variablecrash inapplyPreset()when a sandbox has a policy without anetwork_policiessectionextractPresetEntriesandparseCurrentPolicyfor testabilityProblem
bin/lib/policies.js:94declarescurrentPolicyasconst, but line 136 reassigns it to prependversion: 1. This code path is reached when a sandbox has a policy YAML that doesn't contain anetwork_policies:key — theconstassignment throws at runtime.Fix
Change
const currentPolicytolet currentPolicyon line 94.Test plan
node --test test/policies-helpers.test.js— 9/9 passnode --test test/*.test.js— full suite 61/61 pass🤖 Generated with Claude Code