Webview crash "Unhandled case: [object Object]" — markdownlint diagnostics with non-string `code` field

Resolved 💬 1 comment Opened May 14, 2026 by dbrenndo Closed Jun 12, 2026

Environment

  • Claude Code VS Code Extension: Anthropic.claude-code (May 2026)
  • markdownlint: DavidAnson.vscode-markdownlint
  • macOS Darwin 25.4.0, Opus 4.7 (1M context)

Symptom

After editing a long Markdown file (e.g. CHANGELOG.md), the Claude webview crashes with the banner "Unhandled case: [object Object]". Backend stream continues; UI is frozen. The user cannot send further messages in that webview.

Root Cause

The PostToolUse:Edit hook collects VS Code diagnostics for the edited file and injects them into the conversation stream as hook_additional_context.

markdownlint sets Diagnostic.code as an object of shape { value: "MD022", target: vscode.Uri } (per VS Code Diagnostic API — this is a valid, common pattern used by many language servers and linters).

The extension serializes this via naive string coercion (template literal or String(code)), producing the literal string "[object Object]".

The webview reducer encounters an unknown shape for code and falls into the default error case, rendering the Unhandled case: [object Object] banner.

Evidence

  • Crash session jsonl contained 20+ occurrences of "code": "[object Object]" paired with markdownlint rule messages (MD022, MD031, MD032, MD036, MD040, MD058, MD060).
  • All occurrences inside PostToolUse:Edit hook attachments on long markdown edits.
  • Confirmed by live reproduction during a follow-up session: editing a markdown file triggered the same diagnostic payload.

Suggested Fix

In the diagnostics-injection path, normalize code before serialization:

const codeStr =
  typeof diag.code === 'string' || typeof diag.code === 'number'
    ? String(diag.code)
    : (diag.code && typeof diag.code === 'object' && 'value' in diag.code)
      ? String(diag.code.value)
      : JSON.stringify(diag.code);

Repro

  1. Install DavidAnson.vscode-markdownlint.
  2. Open a Markdown file with 20+ lint warnings (long CHANGELOG.md, README.md).
  3. Have Claude perform an Edit on that file.
  4. Webview crashes when the diagnostics attachment arrives.

Workaround

Workspace setting:

{
  "markdownlint.run": "off",
  "markdownlint.lintWorkspaceGlobs": []
}

Effective after Reload Window. This prevents markdownlint from producing diagnostics that the extension then mis-serializes.

Impact

Any language extension that sets Diagnostic.code as an object (markdownlint is the most common, but the VS Code API explicitly allows this shape) will trigger the same crash on long edits. Workaround per-extension is brittle; root fix is the serialization in the diagnostics-injection path.

View original on GitHub ↗

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