{"record":{"id":"5d9264b787984559","repo":"larksuite/cli","slug":"json-pointer-q-key-q-not-found","errorCode":null,"errorMessage":"json pointer %q: key %q not found","messagePattern":"json pointer %q: key %q not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/binding/json_pointer.go","lineNumber":50,"sourceCode":"\tcurrent := data\n\n\tfor i, raw := range segments {\n\t\t// RFC 6901 unescaping: ~1 → /, ~0 → ~ (order matters).\n\t\tkey, err := decodeJSONPointerSegment(raw)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"json pointer %q: segment %q: %w\", pointer, raw, err)\n\t\t}\n\n\t\tm, ok := current.(map[string]interface{})\n\t\tif !ok {\n\t\t\ttraversed := \"/\" + strings.Join(segments[:i], \"/\")\n\t\t\treturn nil, fmt.Errorf(\"json pointer %q: value at %q is %T, not an object\",\n\t\t\t\tpointer, traversed, current)\n\t\t}\n\n\t\tval, exists := m[key]\n\t\tif !exists {\n\t\t\treturn nil, fmt.Errorf(\"json pointer %q: key %q not found\", pointer, key)\n\t\t}\n\n\t\tcurrent = val\n\t}\n\n\treturn current, nil\n}\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}","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/binding/json_pointer.go#L32-L68","documentation":"When a pointer segment names a key that is absent from the current object, traversal fails with this error. It reports the full pointer and the decoded key that was not found, making it clear which level of the path diverged from the document.","triggerScenarios":"ReadJSONPointer with a pointer whose key does not exist in the map at that level, e.g. \"/accounts/oauth/id\" when only \"accounts.app\" exists.","commonSituations":"Typo in a key; config schema changed between bridge versions (e.g. secret moved from accounts.app to a new block); case mismatch (\"App\" vs \"app\"); querying an optional field that was omitted.","solutions":["Print/inspect the JSON and use an existing key at that level","Fix the key spelling/case in the pointer","Handle the missing key: check presence first or fall back to a default","Verify the document version matches the expected schema"],"exampleFix":"// before\nReadJSONPointer(data, \"/accounts/oauth/id\")\n// after\nReadJSONPointer(data, \"/accounts/app/id\")","handlingStrategy":"try-catch","validationCode":"obj, err := ReadJSONPointer(data, \"/accounts/app\")\nif err == nil {\n    m := obj.(map[string]interface{})\n    if _, ok := m[\"secret\"]; !ok { /* use default */ }\n}","typeGuard":"func keyExists(m map[string]interface{}, key string) bool {\n    _, ok := m[key]\n    return ok\n}","tryCatchPattern":"val, err := binding.ReadJSONPointer(data, ptr)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n    val = defaultValue // degrade gracefully for optional fields\n}","preventionTips":["Validate pointer keys against the schema at config load time","Treat optional fields explicitly instead of assuming presence","Watch for schema changes across bridge versions"],"tags":["json","rfc6901","missing-key"],"backgroundTag":"json-key-not-found","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"}