openai/codex · error · AmendError

failed to lock policy file

Error message

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

What it means

AmendError::LockPolicyFile: acquiring the advisory lock on the policy file at `path` failed. This bounds concurrent amenders; contention or an OS-level lock error surfaces here with the io::Error attached.

Solutions

  1. Check for another codex process concurrently amending the same policy file
  2. Retry with backoff — the lock is normally transient
  3. Inspect the wrapped io::Error if the failure persists (lock unsupported on the filesystem)
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at codex-rs/execpolicy/src/amend.rs:41 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/8fa79b8f7919b17d. Report an issue: GitHub.

Appendix: source

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

    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,
    },
    #[error("failed to read metadata for policy file {path}: {source}")]
    PolicyMetadata {
        path: PathBuf,
        source: std::io::Error,

View on GitHub (pinned to 339751715c)