Skip to content

Incorrect IInspectValue property used instead of scalar value in scope detection #301471

@ShehabSherif0

Description

@ShehabSherif0

Bug

Two IConfigurationValue property accesses introduced in bb18007 use the IInspectValue<T> object property instead of the scalar value property, causing incorrect scope detection.

1. themeConfiguration.ts - findAutoConfigurationTarget()

Line 380 checks settings.userRemote instead of settings.userRemoteValue:

public findAutoConfigurationTarget(key: string) {
    const settings = this.configurationService.inspect(key);
    if (!types.isUndefined(settings.workspaceFolderValue)) {    // ✓ scalar
        return ConfigurationTarget.WORKSPACE_FOLDER;
    } else if (!types.isUndefined(settings.workspaceValue)) {   // ✓ scalar
        return ConfigurationTarget.WORKSPACE;
    } else if (!types.isUndefined(settings.userRemote)) {       // ✗ IInspectValue object
        return ConfigurationTarget.USER_REMOTE;
    }
    return ConfigurationTarget.USER;
}

settings.userRemote is an IInspectValue<T> object ({value?, override?, overrides?}). It can be defined when only language-specific overrides exist in the remote config, even if no actual remote value is set. This causes theme settings to incorrectly target USER_REMOTE scope.

2. commandLineAutoApprover.ts - source target detection

Line 282 checks configInspectValue.workspaceFolder instead of configInspectValue.workspaceFolderValue:

const sourceTarget = (
    checkTarget(configInspectValue.workspaceFolder) ? ConfigurationTarget.WORKSPACE_FOLDER
        : checkTarget(configInspectValue.workspaceValue) ? ConfigurationTarget.WORKSPACE
            : checkTarget(configInspectValue.userRemoteValue) ? ConfigurationTarget.USER_REMOTE
                ...
);

configInspectValue.workspaceFolder is an IInspectValue<T> whose keys are {value, override, overrides}. The checkTarget function looks for tool-pattern keys (e.g., "git*") via hasOwnProperty, which never matches on IInspectValue. This means workspace-folder-scoped auto-approve rules are never detected as such and fall through to a lower-priority scope.

Root Cause

Both are from the same commit (bb18007) and follow the same pattern: the IConfigurationValue<T> interface exposes both scalar values (e.g., userRemoteValue: T) and inspect objects (e.g., userRemote: IInspectValue<T>). The similar naming makes it easy to pick the wrong one.

Fix

  • settings.userRemote -> settings.userRemoteValue
  • configInspectValue.workspaceFolder -> configInspectValue.workspaceFolderValue

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugterminalGeneral terminal issues that don't fall under another label

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions