golang/go · error

parsing JSON error: %v

Error message

parsing JSON error: %v

What it means

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.

Source

Thrown at src/cmd/go/internal/vet/vet.go:401

			return fmt.Errorf("parsing JSON: %v", err)
		}
		for _, units := range tree {
			for analyzer, msg := range units {
				if msg[0] == '[' {
					// []Diagnostic
					var diags []jsonDiagnostic
					if err := json.Unmarshal([]byte(msg), &diags); err != nil {
						return fmt.Errorf("parsing JSON diagnostics: %v", err)
					}
					for _, diag := range diags {
						base.SetExitStatus(1)
						printJSONDiagnostic(analyzer, diag)
					}
				} else {
					// error
					var e jsonError
					if err := json.Unmarshal([]byte(msg), &e); err != nil {
						return fmt.Errorf("parsing JSON error: %v", err)
					}

					base.SetExitStatus(1)
					return errors.New(e.Err)
				}
			}
		}
	}
	return nil
}

var stdouterrMu sync.Mutex // serializes concurrent writes to stdout and stderr

func printJSONDiagnostic(analyzer string, diag jsonDiagnostic) {
	stdouterrMu.Lock()
	defer stdouterrMu.Unlock()

	type posn struct {

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Have the analyzer emit errors as {"err":"<message>"}
  2. Update the analyzer to the current cmd/go vet JSON contract
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: 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).

Common situations: Analyzer writing a free-form error message instead of {"err":"..."}; schema drift after a toolchain update.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/9e825aa6d91a7471. Report an issue: GitHub.