Hmbown/CodeWhale · error
tempdir
Error message
tempdir
What it means
This is a Rust `expect` panic on `tempfile::tempdir()`, which fails when the OS cannot create a temporary directory (e.g. missing TMPDIR, no permissions, or disk full). The test helpers in chat_completions.rs panic early rather than continuing without an isolated temp root, because every subsequent config write depends on it.
Solutions
- Ensure TMPDIR (or /tmp) exists and is writable by the test user before running tests
- Free disk space on the partition backing the temp directory
- Pass an explicit writable directory via `std::env::set_var("TMPDIR", ...)` in test setup
- Replace `expect` with proper error propagation if the helper should fail gracefully
Example fix
// before
let tmp = tempfile::tempdir().expect("tempdir");
// after
let tmp = tempfile::tempdir().expect("tempdir: ensure TMPDIR is writable and has free space"); Defensive patterns
Strategy: validation
Validate before calling
let tmp = tempfile::tempdir().map_err(|e| panic!("tempdir unavailable: {e}; check TMPDIR permissions/disk space"))?; Try / catch
// Rust panics cannot be caught with try/catch; pre-validate the environment assert!(std::env::temp_dir().metadata().map(|m| m.is_dir()).unwrap_or(false), "TMPDIR must be a writable directory");
Prevention
- Verify TMPDIR exists and is writable in CI setup steps
- Monitor disk space on the temp filesystem
- Use tempfile's Builder with explicit .tempdir_in() to a known-writable path
When it happens
Trigger: Calling `app_with_mock_upstream_with_provider_extra`, `app_with_together_mock_upstream`, `app_with_root_deepseek_mock_upstream`, or `app_with_auth_boundary_mock_upstream` in an environment where `tempfile::tempdir()` returns Err: unwritable or nonexistent TMPDIR/tmp, sandboxed CI without /tmp access, or a full temp filesystem.
Common situations: CI runners with read-only or restricted /tmp; Docker containers with tiny tmpfs; macOS/Linux environments where TMPDIR points to a deleted directory.
Understand the failure class
Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.
Related errors
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/7540169c014e3053.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/client.rs:8512
// from model_bound_request_leaves_ordinary_tool_output_unchanged
{
let client = client_with_config_secret_sentinels();
let ordinary = "tests passed: 42\nREADME.md updated\n";
let prepared =
client.prepare_model_bound_request(request_with_tool_result(ordinary.to_string()));
assert_eq!(tool_result_content(&prepared), ordinary);
}
}
/// The `[redaction] model_bound = "disabled"` opt-out, once confirmed on
/// the startup gate, must let the model see tool output byte-for-byte —
/// including configured secrets and credential-shaped values that the
/// default masking would have removed (#5546 keeps code quotable; this
/// opt-out goes further and keeps credentials quotable too).
#[test]
fn confirmed_opt_out_keeps_configured_secrets_visible_to_the_model() {
let _env_lock = crate::test_support::lock_test_env();
let tmp = tempfile::tempdir().expect("tempdir");
let home = tmp.path().join("home");
std::fs::create_dir_all(&home).expect("create isolated home");
let _home = crate::test_support::EnvVarGuard::set("HOME", &home);
let _userprofile = crate::test_support::EnvVarGuard::set("USERPROFILE", &home);
let codewhale_home = tmp.path().join("codewhale-home");
let _codewhale_home =
crate::test_support::EnvVarGuard::set("CODEWHALE_HOME", &codewhale_home);
std::fs::create_dir_all(&codewhale_home).expect("create config home");
std::fs::write(
codewhale_home.join("config.toml"),
"[redaction]\nmodel_bound = \"disabled\"\n",
)
.expect("write opt-out request");
codewhale_config::redaction::record_model_bound_disabled_confirmation(
&codewhale_home.join("config.toml"),
)
.expect("record opt-out confirmation");
View on GitHub (pinned to 73e0f67d83)