{"record":{"id":"00f4cd9b6166b48b","repo":"vitessio/vitess","slug":"cannot-parse-object-value-s","errorCode":null,"errorMessage":"cannot parse object value: %s","messagePattern":"cannot parse object value: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/mysql/json/parser.go","lineNumber":555,"sourceCode":"\t\t}\n\t\tkv.k, s, unescape, err = parseRawKey(s[1:])\n\t\tif err != nil {\n\t\t\treturn nil, s, fmt.Errorf(\"cannot parse object key: %s\", err)\n\t\t}\n\t\tif unescape {\n\t\t\tkv.k = unescapeStringBestEffort(kv.k)\n\t\t}\n\t\ts = skipWS(s)\n\t\tif len(s) == 0 || s[0] != ':' {\n\t\t\treturn nil, s, errors.New(\"missing ':' after object key\")\n\t\t}\n\t\ts = s[1:]\n\n\t\t// Parse value\n\t\ts = skipWS(s)\n\t\tkv.v, s, err = parseValue(s, c, depth)\n\t\tif err != nil {\n\t\t\treturn nil, s, fmt.Errorf(\"cannot parse object value: %s\", err)\n\t\t}\n\t\ts = skipWS(s)\n\t\tif len(s) == 0 {\n\t\t\treturn nil, s, errors.New(\"unexpected end of object\")\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\to.o.sort()\n\t\t\treturn o, s[1:], nil\n\t\t}\n\t\treturn nil, s, errors.New(\"missing ',' after object value\")\n\t}\n}\n\nconst hexDigits = \"0123456789abcdef\"","sourceCodeStart":537,"sourceCodeEnd":573,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/json/parser.go#L537-L573","documentation":"While parsing a JSON object, the value after a valid key:colon failed in parseValue; the error is wrapped as 'cannot parse object value:'. The inner error identifies why the value (number, string, literal, etc.) was rejected.","triggerScenarios":"Parsing `{\"k\": }` (empty value), `{\"k\": q}` (bare word), or an object value that is an oversized number or malformed literal.","commonSituations":"Template-generated JSON where a variable rendered empty; corrupted column/binlog data; hand-edited JSON documents.","solutions":["Fix the invalid value at the reported position in the object","Ensure values are always serialized (never emit empty strings for numbers/objects)","Validate the JSON document with a standard parser before handing it to mysql.ParseJSON"],"exampleFix":"// before\nv, err := mysql.ParseJSON(`{\"k\": }`)\n// after\nv, err := mysql.ParseJSON(`{\"k\": null}`)","handlingStrategy":"try-catch","validationCode":"if !json.Valid([]byte(input)) {\n\treturn fmt.Errorf(\"invalid JSON document: %q\", input)\n}","typeGuard":null,"tryCatchPattern":"v, err := mysql.ParseJSON(input)\nif err != nil {\n\tif strings.Contains(err.Error(), \"cannot parse object value\") {\n\t\t// the value after a key:colon is malformed; reject or repair\n\t}\n\treturn err\n}","preventionTips":["Never interpolate possibly-empty variables into JSON templates — marshal a struct instead","Use encoding/json to build objects so values are always well-formed","Validate documents with json.Valid at ingest boundaries"],"tags":["json","parsing","object"],"backgroundTag":"invalid-json-syntax","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}