{"record":{"id":"7a1cc4867576e02d","repo":"larksuite/cli","slug":"file-provider-json-pointer-q-w","errorCode":null,"errorMessage":"file provider JSON Pointer %q: %w","messagePattern":"file provider JSON Pointer %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/binding/secret_resolve_file.go","lineNumber":92,"sourceCode":"\tcase \"singleValue\":\n\t\t// OpenClaw requires ref.id == SINGLE_VALUE_FILE_REF_ID for singleValue mode\n\t\tif ref.ID != SingleValueFileRefID {\n\t\t\treturn \"\", fmt.Errorf(\"singleValue file provider expects ref id %q, got %q\",\n\t\t\t\tSingleValueFileRefID, ref.ID)\n\t\t}\n\t\t// Entire file content is the secret; trim trailing newline\n\t\treturn strings.TrimRight(content, \"\\r\\n\"), nil\n\n\tcase \"json\":\n\t\t// Parse as JSON, then navigate via JSON Pointer (ref.ID)\n\t\tvar parsed interface{}\n\t\tif err := json.Unmarshal(data, &parsed); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"file provider JSON parse error: %w\", err)\n\t\t}\n\n\t\tvalue, err := ReadJSONPointer(parsed, ref.ID)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"file provider JSON Pointer %q: %w\", ref.ID, err)\n\t\t}\n\n\t\t// Value must be a string\n\t\tstrValue, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn \"\", fmt.Errorf(\"file provider JSON Pointer %q resolved to non-string value\", ref.ID)\n\t\t}\n\t\treturn strValue, nil\n\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unsupported file provider mode %q\", mode)\n\t}\n}\n","sourceCodeStart":74,"sourceCodeEnd":106,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/binding/secret_resolve_file.go#L74-L106","documentation":"The file parsed as JSON, but ReadJSONPointer could not navigate to ref.ID — the pointer targets a missing key, wrong array index, or is malformed. The ref id and the pointer error are wrapped so you can see which path failed.","triggerScenarios":"Calling resolveSecretRef with a {source:\"file\"} SecretRef in json mode where ref.ID does not match any location in the parsed document — e.g. id \"/apiKey\" when the file has \"api_key\", or \"/secrets/0\" when the array is empty.","commonSituations":"Secret file schema changed (renamed keys, added nesting) after the binding config was written; ref id written without the leading \"/\"; case mismatch between id and JSON key; pointing at an index that no longer exists after rotation.","solutions":["Print the file structure (`jq . <path>` or `jq 'paths' <path>`) and set ref.ID to a pointer that exists, e.g. \"/api_key\".","Ensure the pointer starts with \"/\" and escapes \"~\" as \"~0\" and \"/\" as \"~1\" per RFC 6901.","Update the binding config after any secret-file schema change; keep them versioned together."],"exampleFix":"// before: file is {\"secrets\":{\"token\":\"x\"}}, ref id \"/token\"\n{\"source\":\"file\",\"id\":\"/token\"}\n// after\n{\"source\":\"file\",\"id\":\"/secrets/token\"}","handlingStrategy":"validation","validationCode":"var doc any\nraw, _ := os.ReadFile(os.ExpandEnv(pc.Path))\nif json.Unmarshal(raw, &doc) == nil {\n    if _, err := ReadJSONPointer(doc, ref.ID); err != nil {\n        return fmt.Errorf(\"ref id %q does not exist in secret file: %v\", ref.ID, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"secret, err := resolveSecretRef(ctx, ref)\nif err != nil {\n    if strings.Contains(err.Error(), \"JSON Pointer\") {\n        // list paths with `jq 'paths' <file>` and correct ref.ID\n    }\n    return err\n}","preventionTips":["Keep the secret file schema and binding refs versioned together; update both on rename.","Always start pointers with \"/\" and RFC 6901-escape \"~\" and \"/\".","Match key case exactly — JSON keys are case-sensitive.","Verify pointers with `jq '<pointer>' <file>` during config authoring."],"tags":["secrets","file-provider","json-pointer","config"],"backgroundTag":"json-pointer-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"}