Hmbown/CodeWhale · error

write fixture

Error message

write fixture

What it means

A panic from `std::fs::write(&path, ...).expect("write fixture")` — the filesystem write of the fake Codex auth.json file failed after serialization succeeded. Common causes: the canonicalized path is unwritable, the parent directory disappeared, or permission/quota errors on the temp volume.

Solutions

  1. Check write permissions and free space on the temp filesystem (touch $TMPDIR/probe; df -h $TMPDIR).
  2. Re-run with a fresh TMPDIR: TMPDIR=$(mktemp -d) cargo test -p codewhale-tui.
  3. Ensure no tmp-cleaner process deletes the directory between canonicalize and write.
  4. In containers, mount /tmp (or $TMPDIR) as a writable tmpfs.
Defensive patterns

Strategy: validation

Validate before calling

// rust, before writing the fixture
assert!(path.is_file() || !path.exists());
if let Some(dir) = path.parent() { assert!(dir.is_dir(), "fixture parent missing"); }

Try / catch

std::fs::write(&path, bytes)
    .unwrap_or_else(|e| panic!("write fixture {path:?}: {e}"));

Prevention

When it happens

Trigger: `std::fs::write` to the canonicalized tempdir path in `codex_client_uses_one_coherent_external_credential_snapshot` returns Err (permissions, ENOSPC, ENOENT after cleaner sweep, read-only mount).

Common situations: Read-only /tmp in containers, disk full on CI, temp path deleted concurrently, or running tests as a user without write access to TMPDIR.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

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

    #[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()),
                    external_credentials: Some(
                        codewhale_config::ExternalCredentialConsentToml::read_only(
                            codewhale_config::ProviderKind::OpenaiCodex,
                            codewhale_config::ExternalCredentialSource::CodexCli,
                            path.clone(),
                        ),
                    ),
                    ..ProviderConfig::default()
                },
                ..ProvidersConfig::default()

View on GitHub (pinned to 73e0f67d83)