{"record":{"id":"62385c8505f58f3e","repo":"golang/go","slug":"parsing-json-diagnostics-v","errorCode":null,"errorMessage":"parsing JSON diagnostics: %v","messagePattern":"parsing JSON diagnostics: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vet/vet.go","lineNumber":391,"sourceCode":"func printJSONDiagnostics(r io.Reader) error {\n\tstdout, err := io.ReadAll(r)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(stdout) > 0 {\n\t\t// unitchecker emits a JSON map of the form:\n\t\t// output maps Package ID -> Analyzer.Name -> (error | []Diagnostic);\n\t\tvar tree jsonTree\n\t\tif err := json.Unmarshal(stdout, &tree); err != nil {\n\t\t\treturn fmt.Errorf(\"parsing JSON: %v\", err)\n\t\t}\n\t\tfor _, units := range tree {\n\t\t\tfor analyzer, msg := range units {\n\t\t\t\tif msg[0] == '[' {\n\t\t\t\t\t// []Diagnostic\n\t\t\t\t\tvar diags []jsonDiagnostic\n\t\t\t\t\tif err := json.Unmarshal([]byte(msg), &diags); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"parsing JSON diagnostics: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t\tfor _, diag := range diags {\n\t\t\t\t\t\tbase.SetExitStatus(1)\n\t\t\t\t\t\tprintJSONDiagnostic(analyzer, diag)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// error\n\t\t\t\t\tvar e jsonError\n\t\t\t\t\tif err := json.Unmarshal([]byte(msg), &e); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"parsing JSON error: %v\", err)\n\t\t\t\t\t}\n\n\t\t\t\t\tbase.SetExitStatus(1)\n\t\t\t\t\treturn errors.New(e.Err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vet/vet.go#L373-L409","documentation":"A JSON tree entry whose value starts with '[' (the []Diagnostic array form) failed to unmarshal into []jsonDiagnostic. The %v is the unmarshal error.","triggerScenarios":"The analyzer's per-analyzer value is shaped like an array but elements don't match the jsonDiagnostic schema (e.g. missing required fields, wrong types).","commonSituations":"Analyzer emitting a non-standard diagnostic schema; version skew between cmd/go's expected jsonDiagnostic fields and the analyzer output.","solutions":["Update the analyzer to match golang.org/x/tools/go/analysis/unitchecker's Diagnostic JSON schema","Pin analyzer and toolchain versions together"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match unitchecker's Diagnostic JSON fields exactly","Pin analyzer and Go toolchain versions together to avoid schema drift"],"tags":["go","vet","json","analyzer"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}