{"record":{"id":"9e825aa6d91a7471","repo":"golang/go","slug":"parsing-json-error-v","errorCode":null,"errorMessage":"parsing JSON error: %v","messagePattern":"parsing JSON error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vet/vet.go","lineNumber":401,"sourceCode":"\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}\n\treturn nil\n}\n\nvar stdouterrMu sync.Mutex // serializes concurrent writes to stdout and stderr\n\nfunc printJSONDiagnostic(analyzer string, diag jsonDiagnostic) {\n\tstdouterrMu.Lock()\n\tdefer stdouterrMu.Unlock()\n\n\ttype posn struct {","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vet/vet.go#L383-L419","documentation":"A JSON tree entry whose value does NOT start with '[' is treated as a JSON error object; unmarshalling it into jsonError (struct with field Err string) failed. The %v is the unmarshal error.","triggerScenarios":"Analyzer reported an error value that isn't a JSON object with an 'err' field (e.g. a bare string, a number, or an object with a different key).","commonSituations":"Analyzer writing a free-form error message instead of {\"err\":\"...\"}; schema drift after a toolchain update.","solutions":["Have the analyzer emit errors as {\"err\":\"<message>\"}","Update the analyzer to the current cmd/go vet JSON contract"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Emit analyzer errors as {\"err\":\"message\"}","Keep analyzer JSON output stable across versions"],"tags":["go","vet","json","analyzer"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T11:17:21.771Z"}