Reject conflicting remote endpoints for resume and fork (#62065)

Extend the remote endpoint conflict check to `codex resume` and `codex fork` so
conflicting root and subcommand `--remote` values report a command-specific
error before authentication token lookup.

Add regression coverage for both commands with conflicting endpoints and an
unset authentication token environment variable.

GitOrigin-RevId: 7fb7bc3f05d8d17d740b0d82c7cd9b327426c1fb
This commit is contained in:
Eric Traut
2026-11-17 15:32:10 +00:00
committed by copyberry
parent 8b5223dd7b
commit 0cc88d0c74
2 changed files with 40 additions and 4 deletions
+30
View File
@@ -652,6 +652,36 @@ fn remote_exec_rejects_conflicting_endpoints() -> Result<()> {
Ok(())
}
#[test]
fn tui_session_commands_reject_conflicting_remotes_before_token_lookup() -> Result<()> {
const MISSING_TOKEN: &str = "CODEX_TEST_MISSING_TUI_REMOTE_TOKEN";
for command in ["resume", "fork"] {
let output = std::process::Command::new(codex_utils_cargo_bin::cargo_bin("codex")?)
.env_remove(MISSING_TOKEN)
.args([
"--remote",
"wss://a.example:443",
"--remote-auth-token-env",
MISSING_TOKEN,
command,
"--remote",
"wss://b.example:443",
THREAD_ID,
])
.output()?;
let stderr = String::from_utf8(output.stderr)?;
assert!(!output.status.success());
assert!(
stderr.contains(&format!(
"`codex {command}` received conflicting remote server endpoints"
)),
"{command}: {stderr}"
);
assert!(!stderr.contains(MISSING_TOKEN), "{command}: {stderr}");
}
Ok(())
}
#[test]
fn remote_session_commands_validate_config() -> Result<()> {
let cases: &[(&[&str], &str, &str)] = &[