Skip to content

Prevent writing settings to global scope for environment and package managers#1489

Merged
eleanorjboyd merged 3 commits intomicrosoft:mainfrom
eleanorjboyd:yappy-quail
Apr 28, 2026
Merged

Prevent writing settings to global scope for environment and package managers#1489
eleanorjboyd merged 3 commits intomicrosoft:mainfrom
eleanorjboyd:yappy-quail

Conversation

@eleanorjboyd
Copy link
Copy Markdown
Member

@eleanorjboyd eleanorjboyd commented Apr 28, 2026

prevents #1468. Now we no longer save env manager or package manage default values to user settings. If a user wants to save these they can but the extension should not as it could very easily cause disruption across a users projects

@eleanorjboyd eleanorjboyd requested a review from Copilot April 28, 2026 03:47
@eleanorjboyd eleanorjboyd self-assigned this Apr 28, 2026
@eleanorjboyd eleanorjboyd added the bug Issue identified by VS Code Team member as probable bug label Apr 28, 2026
@eleanorjboyd eleanorjboyd marked this pull request as ready for review April 28, 2026 03:50
@eleanorjboyd eleanorjboyd enabled auto-merge (squash) April 28, 2026 03:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents the extension from persisting environment/package manager defaults into User (global) settings, reducing cross-project interference (addresses issue #1468).

Changes:

  • Removed ConfigurationTarget.Global writes for defaultEnvManager and defaultPackageManager in settings helpers.
  • Updated unit tests to assert no global-scope writes occur for these settings.
  • Documented that the extension avoids writing settings to User scope (with a note referencing #1468).
Show a summary per file
File Description
src/features/settings/settingHelpers.ts Removes global-scope persistence for default manager settings.
src/test/features/settings/settingHelpers.unit.test.ts Updates tests to ensure default manager settings aren’t written to global scope.
docs/managing-python-projects.md Adds guidance about settings scope behavior and rationale.

Copilot's findings

Comments suppressed due to low confidence (5)

src/test/features/settings/settingHelpers.unit.test.ts:171

  • Same issue as above: this test can miss user/global writes if the boolean form (true) is used instead of ConfigurationTarget.Global. Consider asserting that there are zero updates for defaultEnvManager regardless of the third argument shape.
            const envManagerUpdates = updateCalls.filter(
                (c) => c.key === 'defaultEnvManager' && c.target === ConfigurationTarget.Global,
            );
            assert.strictEqual(envManagerUpdates.length, 0, 'Should never write to user/global settings');
        });

src/test/features/settings/settingHelpers.unit.test.ts:192

  • Same issue as above: restricting the check to ConfigurationTarget.Global can miss global writes using the boolean form. Consider asserting that defaultPackageManager is never updated when invoked with project: undefined, regardless of target representation.
            const pkgManagerUpdates = updateCalls.filter(
                (c) => c.key === 'defaultPackageManager' && c.target === ConfigurationTarget.Global,
            );
            assert.strictEqual(pkgManagerUpdates.length, 0, 'Should never write to user/global settings');
        });

src/features/settings/settingHelpers.ts:261

  • Same as setAllManagerSettings: edits with project unset are filtered out and now become a no-op. To avoid callers accidentally passing “global” edits and thinking they were saved, consider either rejecting/logging those edits or updating the type/docs to remove the “undefined means global” expectation.
        }
    });

    await Promise.all(promises);
}

src/features/settings/settingHelpers.ts:326

  • Same concern here: project: undefined edits are filtered out, so callers trying to persist a global package manager selection will get a silent no-op. Consider surfacing that (trace/log/return) or tightening the type contract so it’s clear only workspace(-folder) scoped edits are supported.
        }
    });

    await Promise.all(promises);
}

src/test/features/settings/settingHelpers.unit.test.ts:150

  • Same issue as above: checking only for ConfigurationTarget.Global can miss user/global writes if the boolean form (true) is used for the update target. Track the raw target and assert no defaultPackageManager update is attempted in any global form.
            const pkgManagerUpdates = updateCalls.filter(
                (c) => c.key === 'defaultPackageManager' && c.target === ConfigurationTarget.Global,
            );
            assert.strictEqual(pkgManagerUpdates.length, 0, 'Should never write to user/global settings');
        });
  • Files reviewed: 3/3 changed files
  • Comments generated: 4

Comment thread docs/managing-python-projects.md Outdated
Comment thread src/test/features/settings/settingHelpers.unit.test.ts Outdated
Comment thread docs/managing-python-projects.md Outdated
Comment thread src/features/settings/settingHelpers.ts
eleanorjboyd and others added 2 commits April 28, 2026 14:32
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@eleanorjboyd eleanorjboyd merged commit 1eb7b67 into microsoft:main Apr 28, 2026
17 checks passed
StellaHuang95 pushed a commit to StellaHuang95/vscode-python-environments that referenced this pull request Apr 30, 2026
…managers (microsoft#1489)

prevents
microsoft#1468. Now
we no longer save env manager or package manage default values to user
settings. If a user wants to save these they can but the extension
should not as it could very easily cause disruption across a users
projects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants