From 2146e1b82d18e536911bd8bfa93087381a38c17a Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Thu, 2 Apr 2026 12:12:18 -0700 Subject: [PATCH 1/2] test: deflake external bearer auth token tests on Windows (#16604) ## Why `external_bearer_only_auth_manager_uses_cached_provider_token` can fail on Windows when cold `powershell.exe` startup exceeds the provider-auth helper's 1s timeout. When that happens, `AuthManager::resolve_external_api_key_auth()` [logs the resolver error and returns `None`](https://github.com/openai/codex/blob/024b08b411fe/codex-rs/login/src/auth/manager.rs#L1449-L1455), which is exactly the assertion failure from the flake. ## What - Invoke `powershell.exe` explicitly in the Windows provider-auth test helpers in `login/src/auth/auth_tests.rs`. - Increase the helper timeout to `10_000` ms and document why that slack exists. ## Verification - `cargo test -p codex-login` --- codex-rs/login/src/auth/auth_tests.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/codex-rs/login/src/auth/auth_tests.rs b/codex-rs/login/src/auth/auth_tests.rs index 5e38d1e4c1..3ee877872f 100644 --- a/codex-rs/login/src/auth/auth_tests.rs +++ b/codex-rs/login/src/auth/auth_tests.rs @@ -395,7 +395,7 @@ $lines | Select-Object -Skip 1 | Set-Content -Path tokens.txt "#, )?; ( - "powershell".to_string(), + "powershell.exe".to_string(), vec![ "-NoProfile".to_string(), "-ExecutionPolicy".to_string(), @@ -436,7 +436,7 @@ exit 1 #[cfg(windows)] let (command, args) = ( - "powershell".to_string(), + "powershell.exe".to_string(), vec![ "-NoProfile".to_string(), "-ExecutionPolicy".to_string(), @@ -457,7 +457,9 @@ exit 1 serde_json::from_value(json!({ "command": self.command, "args": self.args, - "timeout_ms": 1000, + // `powershell.exe` startup can be slow on loaded Windows CI workers, so leave enough + // slack to avoid turning these auth-cache assertions into a process-launch timing test. + "timeout_ms": 10_000, "refresh_interval_ms": 60000, "cwd": self.tempdir.path(), })) From b1d1c47e63eb8a751f43da5eeab1dec727a2512e Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Thu, 2 Apr 2026 12:21:24 -0700 Subject: [PATCH 2/2] fix: add more detail to test assertion --- codex-rs/core/tests/suite/user_shell_cmd.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/codex-rs/core/tests/suite/user_shell_cmd.rs b/codex-rs/core/tests/suite/user_shell_cmd.rs index c0fe8b5352..f6abb5d621 100644 --- a/codex-rs/core/tests/suite/user_shell_cmd.rs +++ b/codex-rs/core/tests/suite/user_shell_cmd.rs @@ -350,13 +350,22 @@ async fn user_shell_command_does_not_set_network_sandbox_env_var() -> anyhow::Re .submit(Op::RunUserShellCommand { command }) .await?; - let end_event = wait_for_event_match(&test.codex, |ev| match ev { + let ExecCommandEndEvent { + exit_code, + stdout, + stderr, + .. + } = wait_for_event_match(&test.codex, |ev| match ev { EventMsg::ExecCommandEnd(event) => Some(event.clone()), _ => None, }) .await; - assert_eq!(end_event.exit_code, 0); - assert_eq!(end_event.stdout.trim(), "not-set"); + + assert_eq!( + exit_code, 0, + "shell command should execute successfully. stdout=`{stdout}`, stderr=`{stderr}`", + ); + assert_eq!(stdout.trim(), "not-set"); Ok(()) }