Improve handling of config and rules errors for app server clients (#9182)

When an invalid config.toml key or value is detected, the CLI currently
just quits. This leaves the VSCE in a dead state.

This PR changes the behavior to not quit and bubble up the config error
to users to make it actionable. It also surfaces errors related to
"rules" parsing.

This allows us to surface these errors to users in the VSCE, like this:

<img width="342" height="129" alt="Screenshot 2026-01-13 at 4 29 22 PM"
src="https://github.com/user-attachments/assets/a79ffbe7-7604-400c-a304-c5165b6eebc4"
/>

<img width="346" height="244" alt="Screenshot 2026-01-13 at 4 45 06 PM"
src="https://github.com/user-attachments/assets/de874f7c-16a2-4a95-8c6d-15f10482e67b"
/>
This commit is contained in:
Eric Traut
2026-01-13 18:57:09 -07:00
committed by GitHub
parent 5a82a72d93
commit 31d9b6f4d2
17 changed files with 197 additions and 56 deletions

View File

@@ -35,14 +35,14 @@ model_provider = "ollama"
std::fs::write(codex_home.join("config.toml"), config_contents)?;
let CodexCliOutput { exit_code, output } = run_codex_cli(codex_home, cwd).await?;
assert_eq!(1, exit_code, "Codex CLI should exit nonzero.");
assert_ne!(0, exit_code, "Codex CLI should exit nonzero.");
assert!(
output.contains("ERROR: Failed to initialize codex:"),
"expected startup error in output, got: {output}"
);
assert!(
output.contains("failed to read execpolicy files"),
"expected execpolicy read error in output, got: {output}"
output.contains("failed to read rules files"),
"expected rules read error in output, got: {output}"
);
Ok(())
}
@@ -63,7 +63,7 @@ async fn run_codex_cli(
codex_home.as_ref().display().to_string(),
);
let args = vec!["-c".to_string(), "analytics_enabled=false".to_string()];
let args = vec!["-c".to_string(), "analytics.enabled=false".to_string()];
let spawned = codex_utils_pty::spawn_pty_process(
codex_cli.to_string_lossy().as_ref(),
&args,