openai/codex · error · AmendError

failed to write to policy file

Error message

failed to write to policy file {path}: {source}

What it means

AmendError::WritePolicyFile: writing the amended policy content back to `path` failed mid-write. The io::Error source explains the failure; the file lock and file-descriptor handling unwind afterwards.

Solutions

  1. Inspect the wrapped io::Error for the OS cause (ENOSPC, EIO)
  2. Check available disk space on the volume holding the policy file
  3. Retry the amendment; the file lock protects against partial concurrent updates
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at codex-rs/execpolicy/src/amend.rs:36 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/a513714f0d2d213c. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/execpolicy/src/amend.rs:36

    #[error("invalid network rule: {0}")]
    InvalidNetworkRule(String),
    #[error("policy path has no parent: {path}")]
    MissingParent { path: PathBuf },
    #[error("failed to create policy directory {dir}: {source}")]
    CreatePolicyDir {
        dir: PathBuf,
        source: std::io::Error,
    },
    #[error("failed to format prefix tokens: {source}")]
    SerializePrefix { source: serde_json::Error },
    #[error("failed to serialize network rule field: {source}")]
    SerializeNetworkRule { source: serde_json::Error },
    #[error("failed to open policy file {path}: {source}")]
    OpenPolicyFile {
        path: PathBuf,
        source: std::io::Error,
    },
    #[error("failed to write to policy file {path}: {source}")]
    WritePolicyFile {
        path: PathBuf,
        source: std::io::Error,
    },
    #[error("failed to lock policy file {path}: {source}")]
    LockPolicyFile {
        path: PathBuf,
        source: std::io::Error,
    },
    #[error("failed to seek policy file {path}: {source}")]
    SeekPolicyFile {
        path: PathBuf,
        source: std::io::Error,
    },
    #[error("failed to read policy file {path}: {source}")]
    ReadPolicyFile {
        path: PathBuf,
        source: std::io::Error,

View on GitHub (pinned to 339751715c)