VS Code extension crashes on activation when claudeCode.environmentVariables is a plain object

Resolved 💬 1 comment Opened Apr 3, 2026 by bobthearsonist Closed Apr 17, 2026

Bug Description

The Claude Code VS Code extension fails to activate when claudeCode.environmentVariables is set as a plain object instead of an array of {name, value} pairs. This prevents all extension commands from registering, including claude-vscode.editor.openLast, making the extension completely non-functional.

Steps to Reproduce

  1. Set the following in VS Code settings.json:

``json
"claudeCode.environmentVariables": {
"ANTHROPIC_BASE_URL": "http://127.0.0.1:4040/claude"
}
``

  1. Reload VS Code
  2. Click the Claude Code icon in the editor title bar

Expected Behavior

The extension should either:

  • Accept both object and array formats for environmentVariables
  • Validate the setting shape and show a helpful error message
  • Use Array.isArray() before iterating, falling back to [] for non-array values

Actual Behavior

Extension activation crashes with:

TypeError: V is not iterable
    at YH (extension.js:803:7232)
    at new XQ (extension.js:803:8336)
    at Cc6 (extension.js:845:4858)

All commands fail with command 'claude-vscode.editor.openLast' not found since they are registered after the crash point.

Root Cause

In the minified extension.js, the YH function (environment variable resolver) does:

function YH(K) {
    let V = a0("environmentVariables") || [];
    // ...
    for (let B of V)  // crashes here — plain objects are not iterable with for...of
        if (B.name) H[B.name] = B.value || "";
}

The || [] fallback only triggers for falsy values. A plain object {} is truthy, so the fallback is skipped, and for...of on a plain object throws TypeError: V is not iterable.

Suggested Fix

Guard with Array.isArray():

let V = a0("environmentVariables");
if (!Array.isArray(V)) V = [];

Workaround

Change the setting to the correct array format:

"claudeCode.environmentVariables": [
    {"name": "ANTHROPIC_BASE_URL", "value": "http://127.0.0.1:4040/claude"}
]

Environment

  • VS Code Insiders 1.x (build 8c85df126b)
  • Claude Code extension v2.1.89 and v2.1.90 (both affected)
  • Windows 11 Enterprise

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗