vitessio/vitess · error
cannot parse array value: %s
Error message
cannot parse array value: %s
What it means
While parsing a JSON array, one of the element values failed to parse via parseValue; the underlying error is wrapped with 'cannot parse array value:'. This contextualizes a nested parse failure as belonging to an array element.
Source
Thrown at go/mysql/json/parser.go:492
if s[0] == ']' {
v := c.getValue()
v.t = TypeArray
v.a = v.a[:0]
return v, s[1:], nil
}
a := c.getValue()
a.t = TypeArray
a.a = a.a[:0]
for {
var v *Value
var err error
s = skipWS(s)
v, s, err = parseValue(s, c, depth)
if err != nil {
return nil, s, fmt.Errorf("cannot parse array value: %s", err)
}
a.a = append(a.a, v)
s = skipWS(s)
if len(s) == 0 {
return nil, s, errors.New("unexpected end of array")
}
if s[0] == ',' {
s = s[1:]
continue
}
if s[0] == ']' {
s = s[1:]
return a, s, nil
}
return nil, s, errors.New("missing ',' after array value")
}
}View on GitHub (pinned to 01a25a7d17)
Solutions
- Inspect the wrapped inner error to find the offending element and fix the array contents
- Validate the full JSON with a standard parser before calling mysql.ParseJSON
- Fix upstream serialization that produced the broken array
Example fix
// before
v, err := mysql.ParseJSON("[tru]")
// after
v, err := mysql.ParseJSON("[true]") Defensive patterns
Strategy: try-catch
Validate before calling
if !json.Valid([]byte(input)) {
return fmt.Errorf("invalid JSON array document: %q", input)
} Try / catch
v, err := mysql.ParseJSON(input)
if err != nil {
var inner string
if strings.Contains(err.Error(), "cannot parse array value") {
inner = strings.TrimPrefix(err.Error(), "cannot parse array value: ")
// inspect inner cause, fix or reject the array element
}
return fmt.Errorf("array element bad (%s): %w", inner, err)
} Prevention
- Run json.Valid on the whole document before parsing
- Generate arrays with encoding/json, not manual bracket building
- Keep elements non-empty: never emit `[a,]` from templates
When it happens
Trigger: Parsing input like `[tru]`, `[1,]` where an element position contains an invalid value, or an array containing an oversized number.
Common situations: Malformed JSON documents from application concatenation; corrupted JSON values read from a MySQL JSON column or binlog; truncated array payloads.
Related errors
- range %d should be >= %d
- unexpected character %q in JSON
- expected ',' or '}' in object, got %q
- reading JSON object key: %w
- expected ',' or ']' in array, got %q
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/3aedc51e3383e459.
Report an issue: GitHub.