Hmbown/CodeWhale · error

canonical temp root

Error message

canonical temp root

What it means

A panic from `Path::canonicalize().expect("canonical temp root")` in the same Codex credential-snapshot test. canonicalize resolves the tempdir path to an absolute, symlink-free path; it fails if the path no longer exists on disk. In practice this fires when the OS temp directory vanished between creation and canonicalization, or on platforms where resolving the path fails.

Solutions

  1. Confirm the temp directory still exists at canonicalize time; do not drop the TempDir guard before use.
  2. Disable or reconfigure periodic tmp cleaners (systemd-tmpfiles, tmpwatch) that race with the test run.
  3. Point TMPDIR at a stable path (mktemp -d outside the cleaner's sweep scope) and re-run.
  4. If a symlinked TMPDIR is the issue, verify `readlink -f $TMPDIR` resolves to an existing directory.
Defensive patterns

Strategy: validation

Validate before calling

// rust: verify before canonicalize
assert!(temp.path().exists(), "tempdir vanished before canonicalize");
let path = temp.path().canonicalize().expect("canonical temp root");

Prevention

When it happens

Trigger: `temp.path().canonicalize().expect("canonical temp root")` fails because the TempDir was already deleted (e.g. dropped early), TMPDIR is a dangling symlink, or an aggressive tmp cleaner removed the directory mid-test.

Common situations: Tests running in parallel with systemd-tmpfiles or tmpwatch cleaning /tmp, TMPDIR pointing through a broken symlink, or macOS TMPDIR directories being cleaned concurrently.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/51d4e45c4a1fab61. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/client.rs:8254

    const CONFIG_SECRET_SENTINELS: [&str; 8] = [
        "deepseek-config-secret-001",
        "arcee-config-secret-002",
        "moonshot-config-secret-003",
        "openrouter-config-secret-004",
        "together-config-secret-005",
        "xiaomi-config-secret-006",
        "zai-active-config-secret-007",
        "sakana-config-secret-008",
    ];

    #[test]
    fn codex_client_uses_one_coherent_external_credential_snapshot() {
        let _env = crate::test_support::lock_test_env();
        let temp = tempfile::tempdir().expect("credential fixture");
        let path = temp
            .path()
            .canonicalize()
            .expect("canonical temp root")
            .join("auth.json");
        let token_a = crate::test_support::future_test_jwt("a");
        std::fs::write(
            &path,
            serde_json::to_vec(&serde_json::json!({
                "tokens": {"access_token": token_a.clone(), "account_id": "account-a"}
            }))
            .expect("serialize fixture"),
        )
        .expect("write fixture");
        let _auth_path = crate::test_support::EnvVarGuard::set("OPENAI_CODEX_AUTH_FILE", &path);
        let _access = crate::test_support::EnvVarGuard::remove("OPENAI_CODEX_ACCESS_TOKEN");
        let _legacy_access = crate::test_support::EnvVarGuard::remove("CODEX_ACCESS_TOKEN");
        let config = Config {
            provider: Some(ApiProvider::OpenaiCodex.as_str().to_string()),
            providers: Some(ProvidersConfig {
                openai_codex: ProviderConfig {
                    auth_mode: Some("oauth".to_string()),

View on GitHub (pinned to 73e0f67d83)