vitessio/vitess · error

cannot parse object value: %s

Error message

cannot parse object value: %s

What it means

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.

Source

Thrown at go/mysql/json/parser.go:555

		}
		kv.k, s, unescape, err = parseRawKey(s[1:])
		if err != nil {
			return nil, s, fmt.Errorf("cannot parse object key: %s", err)
		}
		if unescape {
			kv.k = unescapeStringBestEffort(kv.k)
		}
		s = skipWS(s)
		if len(s) == 0 || s[0] != ':' {
			return nil, s, errors.New("missing ':' after object key")
		}
		s = s[1:]

		// Parse value
		s = skipWS(s)
		kv.v, s, err = parseValue(s, c, depth)
		if err != nil {
			return nil, s, fmt.Errorf("cannot parse object value: %s", err)
		}
		s = skipWS(s)
		if len(s) == 0 {
			return nil, s, errors.New("unexpected end of object")
		}
		if s[0] == ',' {
			s = s[1:]
			continue
		}
		if s[0] == '}' {
			o.o.sort()
			return o, s[1:], nil
		}
		return nil, s, errors.New("missing ',' after object value")
	}
}

const hexDigits = "0123456789abcdef"

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Fix the invalid value at the reported position in the object
  2. Ensure values are always serialized (never emit empty strings for numbers/objects)
  3. Validate the JSON document with a standard parser before handing it to mysql.ParseJSON

Example fix

// before
v, err := mysql.ParseJSON(`{"k": }`)
// after
v, err := mysql.ParseJSON(`{"k": null}`)
Defensive patterns

Strategy: try-catch

Validate before calling

if !json.Valid([]byte(input)) {
	return fmt.Errorf("invalid JSON document: %q", input)
}

Try / catch

v, err := mysql.ParseJSON(input)
if err != nil {
	if strings.Contains(err.Error(), "cannot parse object value") {
		// the value after a key:colon is malformed; reject or repair
	}
	return err
}

Prevention

When it happens

Trigger: Parsing `{"k": }` (empty value), `{"k": q}` (bare word), or an object value that is an oversized number or malformed literal.

Common situations: Template-generated JSON where a variable rendered empty; corrupted column/binlog data; hand-edited JSON documents.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/00f4cd9b6166b48b. Report an issue: GitHub.