jackc/pgx · error

unexpected escape in quoted string: found '%#v'

Error message

unexpected escape in quoted string: found '%#v'

What it means

Error "unexpected escape in quoted string: found '%#v'" thrown in jackc/pgx.

Source

Thrown at pgtype/hstore.go:378

	p.pos = firstBackslash

	// copy bytes until the end, unescaping backslashes
quotedString:
	for {
		nextB, end := p.consume()
		switch {
		case end:
			return "", errEOSInQuoted
		case nextB == '"':
			break quotedString
		case nextB == '\\':
			// escape: skip the backslash and copy the char
			nextB, end = p.consume()
			if end {
				return "", errEOSInQuoted
			}
			if !(nextB == '\\' || nextB == '"') {
				return "", fmt.Errorf("unexpected escape in quoted string: found '%#v'", nextB)
			}
			builder.WriteByte(nextB)
		default:
			// normal byte: copy it
			builder.WriteByte(nextB)
		}
	}
	return builder.String(), nil
}

// consumePairSeparator consumes the Hstore pair separator ", " or returns an error.
func (p *hstoreParser) consumePairSeparator() error {
	return p.consumeExpected2(',', ' ')
}

// consumeKVSeparator consumes the Hstore key/value separator "=>" or returns an error.
func (p *hstoreParser) consumeKVSeparator() error {
	return p.consumeExpected2('=', '>')

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgtype/hstore.go:378 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04). Data as JSON: /data/errors/b022434fdbc9661e.json. Report an issue: GitHub.