openai/codex · error · SetupFailure
HelperFirewallComInitFailed
HelperFirewallComInitFailed
Error message
CoInitializeEx failed: {hr:?} What it means
Fires in ensure_offline_proxy_allowlist when the COM runtime cannot be initialized via CoInitializeEx(COINIT_APARTMENTTHREADED) — required to use the Windows Firewall COM API (INetFwPolicy2) for adding the offline proxy allowlist rule. A failing HRESULT means COM init failed (e.g. RPC_E_CHANGED_MODE if the thread is already MTA).
Solutions
- Check the HRESULT: RPC_E_CHANGED_MODE means the thread already initialized COM as MTA; adapt or run on a fresh thread
- Ensure CoInitializeEx is called before any other COM usage on this thread
- Wrap the setup step so firewall rule application failures are logged as SetupFailure with the helper-firewall code
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/firewall.rs:65 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/42b10a7e15ddce67.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/firewall.rs:65
friendly_desc: &'a str,
protocol: i32,
local_user_spec: &'a str,
offline_sid: &'a str,
remote_addresses: Option<&'a str>,
remote_ports: Option<&'a str>,
}
pub fn ensure_offline_proxy_allowlist(
offline_sid: &str,
proxy_ports: &[u16],
allow_local_binding: bool,
log: &mut dyn Write,
) -> Result<()> {
let local_user_spec = format!("O:LSD:(A;;CC;;;{offline_sid})");
let hr = unsafe { CoInitializeEx(None, COINIT_APARTMENTTHREADED) };
if hr.is_err() {
return Err(anyhow::Error::new(SetupFailure::new(
SetupErrorCode::HelperFirewallComInitFailed,
format!("CoInitializeEx failed: {hr:?}"),
)));
}
let result = unsafe {
(|| -> Result<()> {
let policy: INetFwPolicy2 = CoCreateInstance(&NetFwPolicy2, None, CLSCTX_INPROC_SERVER)
.map_err(|err| {
anyhow::Error::new(SetupFailure::new(
SetupErrorCode::HelperFirewallPolicyAccessFailed,
format!("CoCreateInstance NetFwPolicy2 failed: {err:?}"),
))
})?;
ensure_local_policy_rules_take_effect(&policy)?;
let rules = policy.Rules().map_err(|err| {
anyhow::Error::new(SetupFailure::new(
SetupErrorCode::HelperFirewallPolicyAccessFailed,View on GitHub (pinned to 339751715c)