Skip to content

[Error] unhandlederror-Cannot change enablement of GitHub Copilot Chat extension because of its extension ki... #312381

Closed

Description

@vs-code-engineering

Error Message

unhandlederror-Cannot change enablement of GitHub Copilot Chat extension because of its extension kind

Stack Trace

    at Ret.throwErrorIfEnablementStateCannotBeChanged (./src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts:242:0)
    at Ret.throwErrorIfCannotChangeEnablement (./src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts:230:0)
    at Ret.setEnablement (./src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts:282:0)
    at async n6.doSetEnablement (./src/vs/browser/extensionsWorkbenchService.ts:3138:0)
    at async Jfe.maybeEnableOrDisableExtension (./src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupContributions.ts:779:0)

Raw Stack Trace (minified)
Error: Cannot change enablement of GitHub Copilot Chat extension because of its extension kind     at Ret.throwErrorIfEnablementStateCannotBeChanged (out/vs/workbench/workbench.desktop.main.js:1813:19298)     at Ret.throwErrorIfCannotChangeEnablement (out/vs/workbench/workbench.desktop.main.js:1813:18916)     at Ret.setEnablement (out/vs/workbench/workbench.desktop.main.js:1813:20214)     at async n6.doSetEnablement (out/vs/workbench/workbench.desktop.main.js:3402:55631)     at async Jfe.maybeEnableOrDisableExtension (out/vs/workbench/workbench.desktop.main.js:3625:48214)

Details

Property Value
Bucket ID 430d5b15-38fb-413a-18ed-6a43f38ef895
Version 1.117.0
Commit 10c8e557
Last Seen Thu Apr 23 2026 23:59:23 GMT+0000 (Coordinated Universal Time)
Platforms Mac, Windows, Linux
Product VSCode

This issue was automatically created from the VS Code Errors Dashboard

Activity

  1. added
    bug
    error-telemetry
    on Apr 24, 2026
  2. vs-code-engineering commented on Apr 24, 2026

    @vs-code-engineering
    Author
  3. vs-code-engineering commented on Apr 24, 2026

    @vs-code-engineering
    ContributorAuthor

    🔍 Error Investigation

    Summary

    ChatTeardownContribution.maybeEnableOrDisableExtension() calls extensionsWorkbenchService.setEnablement() without checking whether the extension's current enablement state permits changes. When the Copilot Chat extension is in DisabledByExtensionKind state — which occurs in remote contexts (SSH, WSL, Dev Containers, tunnels) where the extension's kind doesn't match its install location — setEnablement() throws an unhandled error. With 25,773 hits from 7,808 users on stable 1.117.0, this is a high-impact regression affecting all remote users who have chat.disableAIFeatures enabled.

    Culprit Commit

    No single commit range was available from regression scan comments. The root cause is a missing guard in maybeEnableOrDisableExtension() that has existed since the method was introduced, but the conditions to trigger it became widespread with the following PRs in the 1.116.0–1.117.0 timeframe:

    PR Author Relevance
    #308478 @sandy081 Introduced migration that auto-sets chat.disableAIFeatures to true for users who previously had the extension disabled — greatly increasing the number of users exercising the handleChatDisabled code path
    #308988 @sandy081 Added enable/disable AI features actions + workspace-level tracking
    #310840 @sandy081 Fixed workspace-level enablement handling in ChatTeardownContribution

    The error first appeared in 1.117.0 insiders (commit 173f07e5, April 20) and not in 1.116.0, suggesting a change in 1.117.0 (possibly PR #310840 or a change in the extension's kind/install behavior) created the final conditions for the crash.

    Code Flow

    sequenceDiagram
        participant Config as ConfigurationService
        participant Teardown as ChatTeardownContribution
        participant ExtWB as ExtensionsWorkbenchService
        participant Enable as ExtensionEnablementService
    
        Note over Teardown: Constructor or config change
        Teardown->>Teardown: handleChatDisabled()
        Note over Teardown: chat.disableAIFeatures === true
        Teardown->>ExtWB: setEnablement([copilotChat], DisabledGlobally)
        ExtWB->>Enable: setEnablement(extensions, DisabledGlobally)
        Enable->>Enable: throwErrorIfCannotChangeEnablement()
        Enable->>Enable: getEnablementState() → DisabledByExtensionKind
        Note over Enable: ⚠️ Root cause: no guard<br/>for non-changeable states
        Enable->>Enable: throwErrorIfEnablementStateCannotBeChanged()
        Note over Enable: 💥 Error thrown:<br/>"Cannot change enablement of<br/>GitHub Copilot Chat extension<br/>because of its extension kind"
    
    Loading

    Affected Files

    File Role
    src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupContributions.ts Root cause — maybeEnableOrDisableExtension() (line 778) calls setEnablement without checking current state
    src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts Crash site — throwErrorIfEnablementStateCannotBeChanged() (line 242) throws for DisabledByExtensionKind
    src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts Data flow — doSetEnablement() (line 3138) passes through to enablement service

    Repro Steps

    1. Open VS Code on desktop with a remote connection (SSH, WSL, or Dev Container)
    2. The Copilot Chat extension must be installed in a location that mismatches its extensionKind (e.g., installed remotely but has UI kind) — this causes DisabledByExtensionKind
    3. Set "chat.disableAIFeatures": true in user settings (or have it auto-set by the migration from PR disable copilot chat extension by default and adopt accordingly #308478)
    4. Restart VS Code or trigger a configuration reload
    5. The ChatTeardownContribution constructor calls handleChatDisabled(false), which attempts to disable the extension via setEnablement, which throws

    Fix Proposal

    Fix location: src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupContributions.ts → maybeEnableOrDisableExtension()

    Approach: Before calling this.extensionsWorkbenchService.setEnablement(), check the extension's current enablement state. If the state is one of the non-changeable states (DisabledByExtensionKind, DisabledByEnvironment, DisabledByMalicious, DisabledByVirtualWorkspace, DisabledByAllowlist, DisabledByInvalidExtension), bail out early without calling setEnablement. Alternatively, wrap the setEnablement call in a try/catch to gracefully handle the error. The former approach is preferred as it avoids unnecessary work and makes the intent explicit:

    if extension is found:
        check currentState = extension.enablementState
        if currentState is one of [DisabledByExtensionKind, DisabledByEnvironment, ...]:
            return (cannot change this extension's enablement)
        proceed with setEnablement(...)
    

    Note: The getExtensionsToEnableRecursively() method in extensionEnablementService.ts (line 335) already has a similar guard that skips DisabledByExtensionKind for dependencies — the same pattern should be applied in maybeEnableOrDisableExtension.

    Recommended Owner

    @sandy081 — Author of all related PRs (#308478, #308988, #310840) and the extension enablement area expert. All three PRs that built the chat.disableAIFeatures ↔ extension enablement integration were authored by this developer.

    Generated by errors-investigate · ● 32.5M · ◷

  4. vs-code-engineering commented on Apr 27, 2026

    @vs-code-engineering
    ContributorAuthor

    Insider regression scan — Bucket cca85117 linked (1.118.0-insider, build f2b51f3f). This is the same logical error as bucket 430d5b15 tracked in the stable scan — the bucket ID changed due to minification drift between builds. 21 users affected in the latest insider build.

    Generated by errors-insider-scan

    Generated by errors-regression-scan · ● 9.6M · ◷

  5. vs-code-engineering commented on Apr 27, 2026

    @vs-code-engineering
    Author
  6. added
    ai-generated
    ai-analyzed
    on Apr 28, 2026
  7. vs-code-engineering commented on May 7, 2026

    @vs-code-engineering
    ContributorAuthor

    Stable Release Anomaly Details

    These additional error buckets are tracked by this issue (v1.119.0):

    Bucket ID Users Type
    09a336c4 1,134 new

    The error continues to appear in the latest stable release with a new bucket ID (due to minification changes).

    Generated by errors-stable-scan · ● 7.8M · ◷

  8. dmitrivMS commented on May 9, 2026

    @dmitrivMS
    Collaborator

    Repro Steps

    1. Open WSL, start "code-insiders --transient"
    2. Connect to WSL (install extension, wait for it to finish connecting)
    3. Set "chat.disableAIFeatures": true in user settings
    4. Open dev tools -> console
    5. Reload window

    Actual
    Error in console:
    ERR Cannot change enablement of GitHub Copilot Chat extension because of its extension kind: Error: Cannot change enablement of GitHub Copilot Chat extension because of its extension kind
    at $tt.throwErrorIfEnablementStateCannotBeChanged (vscode-file://vscode-app/c:/Users/dmitriv/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/3b8129f1d0/resources/app/out/vs/workbench/workbench.desktop.main.js:1827:19861)
    at $tt.throwErrorIfCannotChangeEnablement (vscode-file://vscode-app/c:/Users/dmitriv/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/3b8129f1d0/resources/app/out/vs/workbench/workbench.desktop.main.js:1827:19479)
    at $tt.setEnablement (vscode-file://vscode-app/c:/Users/dmitriv/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/3b8129f1d0/resources/app/out/vs/workbench/workbench.desktop.main.js:1827:20777)
    at async o9.doSetEnablement (vscode-file://vscode-app/c:/Users/dmitriv/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/3b8129f1d0/resources/app/out/vs/workbench/workbench.desktop.main.js:3650:55631)
    at async Nve.maybeEnableOrDisableExtension (vscode-file://vscode-app/c:/Users/dmitriv/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/3b8129f1d0/resources/app/out/vs/workbench/workbench.desktop.main.js:3304:48432)

    Expected
    No error.

  9. added a commit that references this issue on May 19, 2026
    efbff4d
  10. added
    unreleased
    insiders-released
    and removed
    unreleased
    on May 19, 2026
  11. locked and limited conversation to collaborators on Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ai-analyzedai-generatedbugerror-telemetryinsiders-releasedrecent-regressionstable-anomaly

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions