{"record":{"id":"ba445adeee14df6a","repo":"openai/codex","slug":"failed-to-read-policy-file-path-source","errorCode":null,"errorMessage":"failed to read policy file {path}: {source}","messagePattern":"failed to read policy file (.+?): (.+?)","errorType":"exception","errorClass":"AmendError","httpStatus":null,"severity":"error","filePath":"codex-rs/execpolicy/src/amend.rs","lineNumber":51,"sourceCode":"        path: PathBuf,\n        source: std::io::Error,\n    },\n    #[error(\"failed to write to policy file {path}: {source}\")]\n    WritePolicyFile {\n        path: PathBuf,\n        source: std::io::Error,\n    },\n    #[error(\"failed to lock policy file {path}: {source}\")]\n    LockPolicyFile {\n        path: PathBuf,\n        source: std::io::Error,\n    },\n    #[error(\"failed to seek policy file {path}: {source}\")]\n    SeekPolicyFile {\n        path: PathBuf,\n        source: std::io::Error,\n    },\n    #[error(\"failed to read policy file {path}: {source}\")]\n    ReadPolicyFile {\n        path: PathBuf,\n        source: std::io::Error,\n    },\n    #[error(\"failed to read metadata for policy file {path}: {source}\")]\n    PolicyMetadata {\n        path: PathBuf,\n        source: std::io::Error,\n    },\n}\n\n/// Note this thread uses advisory file locking and performs blocking I/O, so it should be used with\n/// [`tokio::task::spawn_blocking`] when called from an async context.\npub fn blocking_append_allow_prefix_rule(\n    policy_path: &Path,\n    prefix: &[String],\n) -> Result<(), AmendError> {\n    if prefix.is_empty() {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/execpolicy/src/amend.rs#L33-L69","documentation":"Wraps a std::io::Error from read_to_string on the policy file while loading its existing contents during amendment. Also covers the file containing invalid UTF-8 in some call paths — the existing policy is unreadable, so it cannot be amended in place.","triggerScenarios":"Thrown at codex-rs/execpolicy/src/amend.rs:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped io::Error for the read failure cause","Validate the policy file is valid UTF-8 JSON (corruption may require regenerating it)","Restore the policy file from a known-good state and retry the amendment"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}