openai/codex · error · SetupFailure

HelperFirewallRuleCreateOrAddFailed

HelperFirewallRuleCreateOrAddFailed

Error message

Rules::Remove failed for {internal_name}: {err:?}

What it means

A firewall rule lookup by name succeeded (rules.Item returned Ok), but the subsequent rules.Remove call to delete that rule returned an error HRESULT. This fires during cleanup/re-configuration of the offline proxy allowlist rules when the INetFwRules collection refuses the deletion, for example because the rule is managed by group policy or was concurrently modified.

Solutions

  1. Inspect the HRESULT in the message to determine whether deletion was denied by policy or the rule disappeared concurrently
  2. Remove group policy control over the codex firewall rules or re-run setup after policy refresh
  3. Retry the setup step: the code path treats missing rules as absent (Item check), so a re-run may succeed once the conflicting state clears
  4. Verify the process is elevated, since deleting firewall rules requires administrator rights
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/firewall.rs:216 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/be64f94d2ce80499. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/firewall.rs:216

            Ok(())
        })()
    };

    unsafe {
        CoUninitialize();
    }
    result
}

fn remove_rule_if_present(
    rules: &INetFwRules,
    internal_name: &str,
    log: &mut dyn Write,
) -> Result<()> {
    let name = BSTR::from(internal_name);
    if unsafe { rules.Item(&name) }.is_ok() {
        unsafe { rules.Remove(&name) }.map_err(|err| {
            anyhow::Error::new(SetupFailure::new(
                SetupErrorCode::HelperFirewallRuleCreateOrAddFailed,
                format!("Rules::Remove failed for {internal_name}: {err:?}"),
            ))
        })?;
        log_line(log, &format!("firewall rule removed name={internal_name}"))?;
    }
    Ok(())
}

fn ensure_local_policy_rules_take_effect(policy: &INetFwPolicy2) -> Result<()> {
    let mut modify_state = NET_FW_MODIFY_STATE::default();
    let result = unsafe {
        (Interface::vtable(policy).LocalPolicyModifyState)(
            Interface::as_raw(policy),
            &mut modify_state,
        )
    };
    validate_local_policy_modify_result(result, modify_state)

View on GitHub (pinned to 339751715c)