{"record":{"id":"cc09cbf56ba152e0","repo":"Hmbown/CodeWhale","slug":"tempdir-tests","errorCode":null,"errorMessage":"tempdir","messagePattern":"tempdir","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tools/subagent/tests.rs","lineNumber":6545,"sourceCode":"        .await\n        .get_worker_record(\"agent_cancel_probe\")\n        .expect(\"worker record remains inspectable\");\n    assert_eq!(\n        record\n            .events\n            .iter()\n            .filter(|event| event.status == AgentWorkerStatus::Cancelled)\n            .count(),\n        1,\n        \"repeated stop must not append a second terminal outcome\"\n    );\n}\n\n#[tokio::test]\nasync fn model_wait_cancel_fans_in_once_and_preserves_checkpoint() {\n    use tokio_util::sync::CancellationToken;\n\n    let tmp = tempdir().expect(\"tempdir\");\n    let mut manager = SubAgentManager::new(tmp.path().to_path_buf(), 2);\n    let agent_id = \"agent_model_wait_cancel\".to_string();\n    let (input_tx, _input_rx) = mpsc::unbounded_channel();\n    let mut agent = SubAgent::new(\n        agent_id.clone(),\n        FleetRole::Worker,\n        \"cancel while waiting on provider\".to_string(),\n        make_assignment(),\n        \"deepseek-v4-flash\".to_string(),\n        None,\n        None,\n        input_tx,\n        tmp.path().to_path_buf(),\n        manager.current_session_boot_id.clone(),\n    );\n    agent.checkpoint = Some(make_checkpoint(\n        &agent_id,\n        1,","sourceCodeStart":6527,"sourceCodeEnd":6563,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/tests.rs#L6527-L6563","documentation":"A `tempfile::tempdir().expect(\"tempdir\")` panic in a `#[tokio::test]` in `crates/tui/src/tools/subagent/tests.rs`. The test creates a temporary directory to back a `SubAgentManager` store and asserts creation succeeds; failure aborts the test before any assertions run. The same expect pattern also appears in `crates/app-server/src/chat_completions.rs` test helpers, so the failure family is 'the test harness could not obtain a temp dir'.","triggerScenarios":"`tempfile::tempdir()` returns Err when it cannot create a directory under the system temp root (TMPDIR): read-only /tmp, full disk, missing TMPDIR target, sandboxed CI denying tmpfs writes, or a very long path exceeding filename limits.","commonSituations":"Running tests in a restricted CI container or hermetic sandbox with no writable temp; TMPDIR pointing at a deleted or read-only path; disk quota exhausted during large test runs.","solutions":["Check `echo $TMPDIR` and confirm the directory exists and is writable; fix or unset it to fall back to /tmp.","Free disk space or raise quota if the filesystem holding temp is full.","Run the test outside the sandbox/with write permission for the temp location (e.g. grant the CI job tmpfs write access).","For a more actionable failure, replace expect with a panic message including the underlying io::Error."],"exampleFix":"// before\nlet tmp = tempdir().expect(\"tempdir\");\n// after\nlet tmp = tempdir().unwrap_or_else(|e| panic!(\"tempdir creation failed: {e}; TMPDIR={:?}\", std::env::var(\"TMPDIR\")));","handlingStrategy":"try-catch","validationCode":"// Pre-flight in CI setup:\nlet probe = tempfile::tempdir().expect(\"temp filesystem must be writable for tests\");\n","typeGuard":null,"tryCatchPattern":"let tmp = tempdir().unwrap_or_else(|e| panic!(\"tempdir failed: {e}; check TMPDIR and disk space\"));","preventionTips":["Verify TMPDIR in CI images and keep /tmp writable.","Monitor disk space on test runners.","Surface io::Error details in test panics instead of bare expects."],"tags":["rust","test","tempdir","filesystem","panic"],"backgroundTag":"file-open-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T10:30:35.592Z"}