[BUG] VS Code extension: claude-vscode.editor.open throws "Cannot read properties of null" when a keybinding passes a null sessionId (createPanel guards undefined but not null)

Status Open
Reported on v2.1.251
Maintainer reply None cached
Activity 0 comments · opened Aug 31, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

What's Wrong?

createPanel() in the VS Code extension guards its sessionId parameter against undefined but not against null, then unconditionally calls .startsWith() on it. Any caller that passes an explicit null sessionId — which is the only thing a keybindings.json entry can pass, since JSON has no undefined — makes claude-vscode.editor.open throw before a panel is created.

The failure is silent from the user's point of view: nothing opens, no notification, no error in the Claude Code output channel. The exception only shows up in the extension host log.

This is what the code looks like in 2.1.251 (minified):

createPanel($, Q, J) {
  let X = $ !== void 0 ? NI($) : void 0;   // <-- guards undefined only
  if (X !== void 0) { let K = this.remoteTeleports.get(X); if (K) $ = K }
  if ($) { ... }
  ...
}

function NI($) {
  if (!$.startsWith("remote:")) return;    // <-- throws when $ === null
  return $.slice(7) || void 0
}

null !== undefined, so a null sessionId passes the guard and reaches NI(), where null.startsWith throws.

This is a regression from the remote:-prefix / teleport handling. In 2.1.226 the method began with a plain truthiness check and null was handled correctly:

// 2.1.226
createPanel(e, t, r) {
  if (e) { let a = this.sessionPanels.get(e); if (a) { ... } }
  ...
}

What Should Happen?

A null sessionId should behave exactly like undefined / an omitted argument: open a new conversation in the requested view column. The guard should be a nullish check ($ != null), or NI() should tolerate a non-string input.

Error Messages/Logs

From ~/Library/Application Support/Code/logs/<session>/window*/exthost/exthost.log:

[error] TypeError: Cannot read properties of null (reading 'startsWith')
    at NI  (~/.vscode/extensions/anthropic.claude-code-<version>/extension.js)
    at p8.createPanel (~/.vscode/extensions/anthropic.claude-code-<version>/extension.js)
    at <claude-vscode.editor.open handler> (~/.vscode/extensions/anthropic.claude-code-<version>/extension.js)
    at df._executeContributedCommand (.../extensionHostProcess.js)
    at df.$executeContributedCommand (.../extensionHostProcess.js)
    at i._doInvokeHandler (.../extensionHostProcess.js)
    ...
    claude-vscode.editor.open {"value":"Anthropic.claude-code","_lower":"anthropic.claude-code"}

Nothing is logged to the "Claude Code" output channel, and no error surfaces in the UI.

Steps to Reproduce

  1. Add this to keybindings.json (the third argument is ViewColumn.Active, so the panel opens in the focused editor group):

``json
{
"key": "shift+cmd+l shift+cmd+l",
"command": "runCommands",
"args": {
"commands": [
{ "command": "claude-vscode.editor.open", "args": [null, null, -1] }
]
},
"when": "!config.claudeCode.useTerminal"
}
``

  1. Press the shortcut.
  2. Nothing happens. Developer: Open Extension Logs Folder → exthost.log contains the TypeError above.

The same happens for any invocation of claude-vscode.editor.open with an explicit null first argument, e.g. from runCommands, a task, or another extension.

Workaround: bind claude-vscode.primaryEditor.open with no arguments instead. Its handler is createPanel(v, y, ViewColumn.Active), so with no args both v and y are genuinely undefined and the guard works.

Suggested Fix

- let X = $ !== void 0 ? NI($) : void 0;
+ let X = $ != null ? NI($) : void 0;

or make NI() defensive:

- function NI($) { if (!$.startsWith("remote:")) return; return $.slice(7) || void 0 }
+ function NI($) { if (typeof $ !== "string" || !$.startsWith("remote:")) return; return $.slice(7) || void 0 }

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.226 (verified by reading the shipped bundle — createPanel there starts with if (e) { and never calls the remote: helper). Broken in 2.1.238; still broken in 2.1.251. Versions between 2.1.226 and 2.1.238 not checked.

Claude Code Version

VS Code extension anthropic.claude-code 2.1.251 (defect verified by reading the shipped extension.js; also reproduced at runtime on 2.1.238)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other — VS Code extension native panel (not the integrated terminal)

Additional Information

VS Code 1.134.0, macOS (arm64).

Since keybindings.json is JSON, null is the only way to skip a positional argument while still supplying a later one. Any user who binds claude-vscode.editor.open to pick a specific view column has to pass null for the first two parameters, so this breaks that entire pattern.

View original on GitHub ↗