{"record":{"id":"9b9a9acc87066482","repo":"vitessio/vitess","slug":"unescapeid-err-no-outer-backticks-found-in-the-id","errorCode":null,"errorMessage":"UnescapeID err: no outer backticks found in the identifier '%s'","messagePattern":"UnescapeID err: no outer backticks found in the identifier '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/sqlescape/ids.go","lineNumber":82,"sourceCode":"\n\tif l == 1 {\n\t\tif in[0] == '`' {\n\t\t\treturn \"\", errors.New(\"UnescapeID err: invalid input identifier '`'\")\n\t\t}\n\t\treturn in, nil\n\t}\n\n\tfirst, last := in[0], in[l-1]\n\n\tif first == '`' && last != '`' {\n\t\treturn \"\", fmt.Errorf(\"UnescapeID err: unexpected single backtick at position %d in '%s'\", 0, in)\n\t}\n\tif first != '`' && last == '`' {\n\t\treturn \"\", fmt.Errorf(\"UnescapeID err: unexpected single backtick at position %d in '%s'\", l, in)\n\t}\n\tif first != '`' && last != '`' {\n\t\tif idx := strings.IndexByte(in, '`'); idx != -1 {\n\t\t\treturn \"\", fmt.Errorf(\"UnescapeID err: no outer backticks found in the identifier '%s'\", in)\n\t\t}\n\t\treturn in, nil\n\t}\n\n\tin = in[1 : l-1]\n\n\tif found := strings.Contains(in, \"`\"); !found {\n\t\treturn in, nil\n\t}\n\n\tvar buf strings.Builder\n\tbuf.Grow(len(in))\n\n\tfor i := 0; i < len(in); i++ {\n\t\tbuf.WriteByte(in[i])\n\n\t\tif i < len(in)-1 && in[i] == '`' {\n\t\t\tif in[i+1] == '`' {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/sqlescape/ids.go#L64-L100","documentation":"Returned by sqlescape.UnescapeID when the identifier is not fully wrapped in outer backticks, so there are no delimiters to strip.","triggerScenarios":"Calling UnescapeID on strings like \"ta`ble\" — inner backtick, no outer quoting.","commonSituations":"Partially escaped strings (only inner content escaped), round-tripping through systems that stripped the outer backticks, hand-built identifiers.","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"],"exampleFix":"// before\nname, _ := sqlescape.UnescapeID(alreadyEscapedInner)\n// after\nname := sqlescape.EscapeID(rawName) // escape fresh from the raw name","handlingStrategy":"validation","validationCode":"func needsUnescape(in string) bool {\n\treturn len(in) >= 2 && in[0] == '`' && in[len(in)-1] == '`'\n}","typeGuard":"func isPlainOrQuotedID(in string) bool {\n\tif !strings.Contains(in, \"`\") { return true }\n\treturn len(in) >= 2 && in[0] == '`' && in[len(in)-1] == '`'\n}","tryCatchPattern":null,"preventionTips":["Only call UnescapeID on strings produced by EscapeID","Track whether an identifier is already raw to skip unnecessary unescaping"],"tags":["go","sql","identifier","parsing"],"backgroundTag":"invalid-identifier","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}