vitessio/vitess · error
UnescapeID err: no outer backticks found in the identifier '
Error message
UnescapeID err: no outer backticks found in the identifier '%s'
What it means
Returned by sqlescape.UnescapeID when the identifier is not fully wrapped in outer backticks, so there are no delimiters to strip.
Source
Thrown at go/sqlescape/ids.go:82
if l == 1 {
if in[0] == '`' {
return "", errors.New("UnescapeID err: invalid input identifier '`'")
}
return in, nil
}
first, last := in[0], in[l-1]
if first == '`' && last != '`' {
return "", fmt.Errorf("UnescapeID err: unexpected single backtick at position %d in '%s'", 0, in)
}
if first != '`' && last == '`' {
return "", fmt.Errorf("UnescapeID err: unexpected single backtick at position %d in '%s'", l, in)
}
if first != '`' && last != '`' {
if idx := strings.IndexByte(in, '`'); idx != -1 {
return "", fmt.Errorf("UnescapeID err: no outer backticks found in the identifier '%s'", in)
}
return in, nil
}
in = in[1 : l-1]
if found := strings.Contains(in, "`"); !found {
return in, nil
}
var buf strings.Builder
buf.Grow(len(in))
for i := 0; i < len(in); i++ {
buf.WriteByte(in[i])
if i < len(in)-1 && in[i] == '`' {
if in[i+1] == '`' {View on GitHub (pinned to 01a25a7d17)
Solutions
- Always wrap with EscapeID before expecting UnescapeID to work
- If the string is already unescaped, skip UnescapeID (or check for outer backticks first)
- Fix the code path that strips outer backticks but leaves escaped inner ones
Example fix
// before name, _ := sqlescape.UnescapeID(alreadyEscapedInner) // after name := sqlescape.EscapeID(rawName) // escape fresh from the raw name
Defensive patterns
Strategy: validation
Validate before calling
func needsUnescape(in string) bool {
return len(in) >= 2 && in[0] == '`' && in[len(in)-1] == '`'
} Type guard
func isPlainOrQuotedID(in string) bool {
if !strings.Contains(in, "`") { return true }
return len(in) >= 2 && in[0] == '`' && in[len(in)-1] == '`'
} Prevention
- Only call UnescapeID on strings produced by EscapeID
- Track whether an identifier is already raw to skip unnecessary unescaping
When it happens
Trigger: Calling UnescapeID on strings like "ta`ble" — inner backtick, no outer quoting.
Common situations: Partially escaped strings (only inner content escaped), round-tripping through systems that stripped the outer backticks, hand-built identifiers.
Related errors
- UnescapeID err: unexpected single backtick at position %d in
- UnescapeID err: invalid input identifier '%s'
- unknown SQL type %q at %s
- --batch-size only allowed when all queries are CREATE TABLE|
- missing value for 'rate'
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/9b9a9acc87066482.
Report an issue: GitHub.