{"record":{"id":"810e6ee05e603fdb","repo":"larksuite/cli","slug":"invalid-escape-c-must-be-0-or-1","errorCode":null,"errorMessage":"invalid escape: ~%c must be ~0 or ~1","messagePattern":"invalid escape: ~%c must be ~0 or ~1","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/binding/json_pointer.go","lineNumber":75,"sourceCode":"}\n\nfunc decodeJSONPointerSegment(raw string) (string, error) {\n\tvar out strings.Builder\n\tfor i := 0; i < len(raw); i++ {\n\t\tif raw[i] != '~' {\n\t\t\tout.WriteByte(raw[i])\n\t\t\tcontinue\n\t\t}\n\t\tif i+1 >= len(raw) {\n\t\t\treturn \"\", fmt.Errorf(\"invalid escape: ~ must be followed by 0 or 1\")\n\t\t}\n\t\tswitch raw[i+1] {\n\t\tcase '0':\n\t\t\tout.WriteByte('~')\n\t\tcase '1':\n\t\t\tout.WriteByte('/')\n\t\tdefault:\n\t\t\treturn \"\", fmt.Errorf(\"invalid escape: ~%c must be ~0 or ~1\", raw[i+1])\n\t\t}\n\t\ti++\n\t}\n\treturn out.String(), nil\n}\n","sourceCodeStart":57,"sourceCodeEnd":81,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/binding/json_pointer.go#L57-L81","documentation":"Same escape-validation rule, but for a '~' followed by a character other than '0' or '1'. RFC 6901 defines only ~0 and ~1; any other combination (e.g. ~2, ~x) is invalid and rejected with the offending pair shown in the message.","triggerScenarios":"Pointer segment contains \"~2\", \"~x\", \"~~\" (second ~ treated as the follower), etc., passed to ReadJSONPointer.","commonSituations":"Keys literally containing '~~' or '~<digit>' sequences written unescaped; copying pointer syntax from other standards that allow more escapes; regex or glob characters bleeding into the pointer string.","solutions":["Escape each literal '~' as '~0': key \"a~2b\" → segment \"a~02b\"","Only ~0 and ~1 are valid — rewrite any other '~X' sequence","Audit the source string for stray '~' characters"],"exampleFix":"// before\nReadJSONPointer(data, \"/key~2name\")\n// after\nReadJSONPointer(data, \"/key~02name\")","handlingStrategy":"validation","validationCode":"var validEscape = regexp.MustCompile(`(^|[^~])~[01]`)\nfunc escapesOK(ptr string) bool { return validEscape.MatchString(ptr) || !strings.Contains(ptr, \"~\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only ~0 and ~1 exist in RFC 6901 — escape all other '~X' as '~0X'","Run a pointer lint/regex check before calling ReadJSONPointer"],"tags":["json","rfc6901","escaping"],"backgroundTag":"invalid-json-pointer","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}