openai/codex · error · AmendError
failed to serialize network rule field
Error message
failed to serialize network rule field: {source} What it means
Wraps a serde_json::Error when serializing a network rule field into the policy JSON fails during amendment. Like SerializePrefix, it signals an internal invariant violation rather than an expected user-facing condition.
Solutions
- Inspect the wrapped serde_json::Error source
- Verify the network rule passed to amend was validated/normalized (InvalidNetworkRule is reported earlier for bad rules)
- Report a bug if reproducible with well-formed rules
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at codex-rs/execpolicy/src/amend.rs:29 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/ff678d7a330d6060.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/execpolicy/src/amend.rs:29
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,
},
#[error("failed to lock policy file {path}: {source}")]
LockPolicyFile {
path: PathBuf,
source: std::io::Error,
},
#[error("failed to seek policy file {path}: {source}")]
SeekPolicyFile {View on GitHub (pinned to 339751715c)