openai/codex · error · AmendError

failed to create policy directory

Error message

failed to create policy directory {dir}: {source}

What it means

Wraps a std::io::Error from create_dir_all when the amend operation tries to create the parent directory of the policy file and directory creation fails (permissions, read-only filesystem, path component is a file, etc.).

Solutions

  1. Inspect the wrapped io::Error source for the OS-level cause (permissions, ENOSPC, ENOTDIR)
  2. Verify the parent path does not collide with an existing file
  3. Run with sufficient filesystem permissions or choose a writable policy directory
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at codex-rs/execpolicy/src/amend.rs:22 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/5d4af03e48109241. Report an issue: GitHub.

Appendix: source

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

use std::io::SeekFrom;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;

use crate::decision::Decision;
use crate::rule::NetworkRuleProtocol;
use crate::rule::normalize_network_rule_host;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum AmendError {
    #[error("prefix rule requires at least one token")]
    EmptyPrefix,
    #[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,
    },

View on GitHub (pinned to 339751715c)