Repository navigation
fix: read developer override settings from user settings only - #230
dungdong-aws merged 6 commits into
Conversation
|
ashishrp-aws
left a comment
There was a problem hiding this comment.
🤖 AI-assisted review at 5f6748f.
Approving. In a release build this closes the workspace-settings route:
- The gate. It is now
_getGlobalValue('forceDevMode') !== true. A workspaceforceDevMode: false, or any workspace or folder value, no longer opens it, and an explicit userfalsekeeps it closed. - Every read uses user scope only. Values come from
inspect(key).globalValue, cast with the declared type, and any cast failure falls back to the default. I checked that every consumer goes throughDevSettings.get, includinggetServiceConfigforcodewhispererService,amazonqLsp,amazonqWorkspaceLspandcloudformationLsp, plusendpointsandtelemetryEndpoint. Nothing readsaws.dev.*throughvscode.workspace.getConfigurationdirectly, so there's no bypass. isDevMode()follows the same rule, because the overridden_isSetandgetboth read user scope only.unset()is in-memory only (it trimstrappedSettings), so calling it from a getter doesn't write to settings.- Tests and CI. The tests cover workspace
forceDevModetrue or false with workspace endpoints, usertruewith workspace endpoints, userfalse, a workspacefalsealongside usertrue, and the non-release path. CI is green.
Should fix (follow-up):
- Pre-release builds still honour workspace values.
isReleaseVersion()is false for any semver pre-release, including the99.0.0-devbeta builds (env.ts:39-51). Anyone running a beta or pre-release VSIX is still exposed to the same repo-suppliedcodewhispererServiceendpoint. Unless only builds from source should keep workspace overrides, apply the user-only read whenever the build isn't a local dev build, or at least whenisBeta()is true. - Defense in depth: let VS Code enforce the scope. Only
aws.dev.amazonqLspis declared inpackage.json, with"scope": "machine". The rest (codewhispererService,endpoints,telemetryEndpoint,amazonqWorkspaceLsp,cloudformationLsp,ssoCacheDirectory, …) are undeclared, so VS Code accepts them from any scope and this check is the only guard. Declaring them with"scope": "machine"(or"application") makes VS Code drop workspace values before the extension sees them.
Non-blocking:
- Stale trapped settings. If a user turns
forceDevModeoff at runtime,getUserOverridereturns defaults but leaves earlier entries intrappedSettings. The dev-mode UI keeps listing them until reload. ClearingtrappedSettingswhen the gate is closed would fix that. - Description. It's empty, which is the right call for a public repo before the advisory. A one-line summary ("
aws.dev.*settings are read from user settings only in release builds") would still help.
|
Addressed the review follow-ups and changelog automation comment in
|
ashishrp-aws
left a comment
There was a problem hiding this comment.
🤖 AI-assisted re-review at 6cbc1ce, against my review on 5f6748f.
Approving. Both follow-ups are addressed.
- ✅ Pre-release and beta builds are covered.
devOverridesAreUserScoped()isisReleaseVersion(true) && !isExtensionDevelopmentHost(), so every packaged build, stable or pre-release, readsaws.dev.*from user settings only. - ✅ The dev-host exception can't be set by a repo. It uses
ExtensionContext.extensionMode === Development, which a workspace can't set, instead of the webpack env heuristic. It also fails closed: before globals are initialised,isExtensionDevelopmentHost()is false, so the scope stays user-only. - ✅ Stale trapped settings are cleared. That happens on a
forceDevModechange, inisDevMode()and ingetUserOverride, and a failed cast nowunsets its key. - ✅ New:
aws.dev.logfileis also read from user scope only, since a repo could otherwise pick the log destination. - Lifecycle.
DefaultTelemetryClient.confignow initialises lazily, so it no longer reads settings before activation, and theDevSettingslistener is disposed with the extension. - CI is green and the changelog entry is added.
Non-blocking:
- Declare the scope in
package.jsontoo. These keys still aren't declared with"scope": "machine", so this code remains the only guard. Declaring them lets VS Code drop workspace values as well. - Double registration.
DevSettings.instanceis pushed intocontext.subscriptionsin bothactivateAmazonQCommonanddev/activation.ts, so it's disposed twice. That's harmless ifdisposeis idempotent, but one owner would be cleaner.
|
Addressed the latest review comments in
|
606ecd0
into
Amazon-Q-Developer:feature/dungdong
Summary
aws.dev.*overrides from user settings in packaged stable and pre-release builds.machinescope so workspace and workspace-folder settings are rejected by the platform.forceDevModeis disabled.Verification
npm run testCompile -w packages/amazonqgit diff --check