{"record":{"id":"3aedc51e3383e459","repo":"vitessio/vitess","slug":"cannot-parse-array-value-s","errorCode":null,"errorMessage":"cannot parse array value: %s","messagePattern":"cannot parse array value: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/mysql/json/parser.go","lineNumber":492,"sourceCode":"\n\tif s[0] == ']' {\n\t\tv := c.getValue()\n\t\tv.t = TypeArray\n\t\tv.a = v.a[:0]\n\t\treturn v, s[1:], nil\n\t}\n\n\ta := c.getValue()\n\ta.t = TypeArray\n\ta.a = a.a[:0]\n\tfor {\n\t\tvar v *Value\n\t\tvar err error\n\n\t\ts = skipWS(s)\n\t\tv, s, err = parseValue(s, c, depth)\n\t\tif err != nil {\n\t\t\treturn nil, s, fmt.Errorf(\"cannot parse array value: %s\", err)\n\t\t}\n\t\ta.a = append(a.a, v)\n\n\t\ts = skipWS(s)\n\t\tif len(s) == 0 {\n\t\t\treturn nil, s, errors.New(\"unexpected end of array\")\n\t\t}\n\t\tif s[0] == ',' {\n\t\t\ts = s[1:]\n\t\t\tcontinue\n\t\t}\n\t\tif s[0] == ']' {\n\t\t\ts = s[1:]\n\t\t\treturn a, s, nil\n\t\t}\n\t\treturn nil, s, errors.New(\"missing ',' after array value\")\n\t}\n}","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/json/parser.go#L474-L510","documentation":"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.","triggerScenarios":"Parsing input like `[tru]`, `[1,]` where an element position contains an invalid value, or an array containing an oversized number.","commonSituations":"Malformed JSON documents from application concatenation; corrupted JSON values read from a MySQL JSON column or binlog; truncated array payloads.","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"],"exampleFix":"// before\nv, err := mysql.ParseJSON(\"[tru]\")\n// after\nv, err := mysql.ParseJSON(\"[true]\")","handlingStrategy":"try-catch","validationCode":"if !json.Valid([]byte(input)) {\n\treturn fmt.Errorf(\"invalid JSON array document: %q\", input)\n}","typeGuard":null,"tryCatchPattern":"v, err := mysql.ParseJSON(input)\nif err != nil {\n\tvar inner string\n\tif strings.Contains(err.Error(), \"cannot parse array value\") {\n\t\tinner = strings.TrimPrefix(err.Error(), \"cannot parse array value: \")\n\t\t// inspect inner cause, fix or reject the array element\n\t}\n\treturn fmt.Errorf(\"array element bad (%s): %w\", inner, err)\n}","preventionTips":["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"],"tags":["json","parsing","array"],"backgroundTag":"invalid-json-syntax","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}