[BUG] IDE diagnostics report "code": "[object Object]" for object-form Diagnostic.code
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
IDE diagnostics from the VS Code extension report "code": "[object Object]" for every diagnostic whose Diagnostic.code uses the object form { value, target }. VS Code types code as string | number | { value: string | number; target: Uri }, and many language extensions use the object form to link a rule to its documentation. In a C# workspace, compiler errors and most analyzer hints use it, and Dart (#59160) and markdownlint (#59220) do too. Plain string and number codes are unaffected, for example Roslynator's RCS1124FadeOut.
In one workspace-wide getDiagnostics call on a C# repository, all 974 errors and 6,947 of the 8,303 hints had "code": "[object Object]". Claude cannot tell which rule a diagnostic belongs to, so it cannot look the rule up, suppress it by ID, or group the results by code.
The cause is the diagnostic serializer in the extension's extension.js (2.1.281, minified names):
function kE0($){return $.map((J)=>({message:J.message,severity:DX.DiagnosticSeverity[J.severity],range:{/* … */},source:J.source,code:J.code?.toString()}))}
J.code?.toString() on a { value, target } object returns "[object Object]". The same serializer (ON) backs both the getDiagnostics MCP tool and the DiagnosticTracking hook that attaches new diagnostics after an Edit or Write, so both paths are affected.
This was reported for the Edit path in #59160 and #59220. The stale bot closed both as not planned on 2026-06-12 without a maintainer response, and both are now locked, so this issue re-files them as their closing comment asks.
What Should Happen?
code carries the diagnostic's code value, for example "CS0115". For the object form, that means serializing code.value:
code: typeof J.code === "object" && J.code !== null ? String(J.code.value) : J.code?.toString()
Error Messages/Logs
Two of the four entries from a single-file getDiagnostics call, with the path redacted:
[
{
"uri": "file:///<workspace>/<path>/InMemoryPubSub.cs",
"diagnostics": [
{
"message": "'InMemoryPubSub.OnSendAsync<TMessage>(string, TMessage, CancellationToken)': no suitable method found to override",
"severity": "Error",
"range": { "start": { "line": 21, "character": 33 }, "end": { "line": 21, "character": 44 } },
"code": "[object Object]"
},
{
"message": "Use primary constructor",
"severity": "Hint",
"range": { "start": { "line": 12, "character": 11 }, "end": { "line": 12, "character": 25 } },
"code": "[object Object]"
}
]
}
]
A markdownlint warning as attached to the conversation after a Write on 2.1.281:
⚠ [Line 1:1] MD041/first-line-heading/first-line-h1: First line in a file should be a top-level heading [[object Object]] (markdownlint)
Steps to Reproduce
- Open a folder containing a .NET project in VS Code with the C# extension (
ms-dotnettools.csharp) installed, and wait for it to load the project. - Open a
.csfile that has a compiler error or an analyzer hint. - In Claude Code, ask Claude to call
getDiagnosticsfor that file, or to make any edit to it so the post-edit diagnostics are attached. - Every entry reported by the C# extension has
"code": "[object Object]".
Any language extension that uses object-form codes reproduces it. #59160 and #59220 have repros for Dart and markdownlint.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.281 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
- VS Code 1.139.0
- C# extension
ms-dotnettools.csharp2.160.4, with C# Dev Kitms-dotnettools.csdevkit3.40.204 - Ubuntu 26.04.1 LTS
_Drafted by Claude (Anthropic AI assistant)._