Hmbown/CodeWhale · error

credential fixture

Error message

credential fixture

What it means

This is a Rust `expect` panic on `tempfile::tempdir()` inside the test `codex_client_uses_one_coherent_external_credential_snapshot` (crates/tui/src/client.rs). The test creates a temporary directory to hold a fake Codex auth.json credential file; if the OS refuses to create a temp dir, the test aborts with the message 'credential fixture'. tempfile only fails here when the platform's temporary directory cannot be created or accessed.

Solutions

  1. Verify TMPDIR (or %TEMP%) is set and points to an existing, writable directory before running tests.
  2. Free disk space on the volume holding the temp directory (df -h /tmp).
  3. Run the test with an explicit writable temp root, e.g. TMPDIR=$(mktemp -d) cargo test -p codewhale-tui.
  4. If in a container, mount a writable tmpfs at /tmp or run with correct ownership (not root-owned read-only).

Example fix

// before
let temp = tempfile::tempdir().expect("credential fixture");
// after (shell, before running tests)
// export TMPDIR=$(mktemp -d) && cargo test codex_client_uses_one_coherent_external_credential_snapshot
Defensive patterns

Strategy: validation

Validate before calling

// shell, before running tests
[ -d "$TMPDIR" ] && [ -w "$TMPDIR" ] || { echo "TMPDIR missing/unwritable"; exit 1; }

Prevention

When it happens

Trigger: Calling `tempfile::tempdir().expect("credential fixture")` in a test when the OS temp directory (TMPDIR on Linux, %TEMP% on Windows) is unwritable, missing, full, or when TMPDIR points to a path that does not exist.

Common situations: Running the test suite in sandboxes/containers with a read-only or unset TMPDIR, CI runners with a full /tmp, or hardened environments where the temp root has restrictive permissions.

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/6663d67144f99023. Report an issue: GitHub.

Appendix: source

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

                .is_empty()
        );
    }

    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 {

View on GitHub (pinned to 73e0f67d83)