openai/codex · error · Error

expected example to not match rule

Error message

expected example to not match rule `{rule}`: {example}

What it means

Fired during policy self-testing: an example declared to NOT match a specific rule actually does match it, contradicting the negative-test annotation. Payload names the rule and the offending example.

Solutions

  1. Narrow the offending rule so it no longer matches the example
  2. Remove the negative-test annotation if the match is actually desired
  3. Change the example if it was intended to exercise a different rule
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/execpolicy/src/error.rs:43 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/5e028efe669f1d7e. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/execpolicy/src/error.rs:43

pub enum Error {
    #[error("invalid decision: {0}")]
    InvalidDecision(String),
    #[error("invalid pattern element: {0}")]
    InvalidPattern(String),
    #[error("invalid example: {0}")]
    InvalidExample(String),
    #[error("invalid rule: {0}")]
    InvalidRule(String),
    #[error(
        "expected every example to match at least one rule. rules: {rules:?}; unmatched examples: \
         {examples:?}"
    )]
    ExampleDidNotMatch {
        rules: Vec<String>,
        examples: Vec<String>,
        location: Option<ErrorLocation>,
    },
    #[error("expected example to not match rule `{rule}`: {example}")]
    ExampleDidMatch {
        rule: String,
        example: String,
        location: Option<ErrorLocation>,
    },
    #[error("starlark error: {0}")]
    Starlark(StarlarkError),
}

impl Error {
    pub fn with_location(self, location: ErrorLocation) -> Self {
        match self {
            Error::ExampleDidNotMatch {
                rules,
                examples,
                location: None,
            } => Error::ExampleDidNotMatch {
                rules,

View on GitHub (pinned to 339751715c)