{"record":{"id":"e9283b9d835c7e21","repo":"Hmbown/CodeWhale","slug":"home","errorCode":null,"errorMessage":"home","messagePattern":"home","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/client.rs","lineNumber":7862,"sourceCode":"        assert_eq!(requests.len(), 1);\n        assert_codewhale_bearer(&requests[0]);\n        assert_eq!(\n            requests[0]\n                .headers\n                .get(\"anthropic-version\")\n                .and_then(|value| value.to_str().ok()),\n            Some(\"2023-06-01\")\n        );\n    }\n\n    /// A catalog row stating `codewhale.protocol = \"responses\"` must dispatch\n    /// to the account API's Responses surface — `{base}/responses` — not the\n    /// Chat Completions default its `openai/` namespace alone would imply.\n    #[tokio::test]\n    async fn codewhale_responses_catalog_row_dispatches_to_responses_endpoint() {\n        let _env = crate::test_support::lock_test_env();\n        let _live = crate::provider_lake::lock_live_snapshot();\n        let home = tempfile::tempdir().expect(\"home\");\n        let _home = crate::test_support::EnvVarGuard::set(\"CODEWHALE_HOME\", home.path());\n        crate::provider_catalog_live::reset_cache_for_test();\n        crate::provider_lake::clear_live_snapshot();\n\n        let server = MockServer::start().await;\n        Mock::given(method(\"POST\"))\n            .and(path(\"/v1/responses\"))\n            .respond_with(\n                ResponseTemplate::new(200)\n                    .insert_header(\"Content-Type\", \"text/event-stream\")\n                    .set_body_string(concat!(\n                        \"data: {\\\"type\\\":\\\"response.completed\\\",\\\"response\\\":{\\\"status\\\":\\\"completed\\\"\",\n                        \",\\\"usage\\\":{\\\"input_tokens\\\":3,\\\"output_tokens\\\":1}}}\\n\\n\",\n                        \"data: [DONE]\\n\\n\"\n                    )),\n            )\n            .expect(1)\n            .mount(&server)","sourceCodeStart":7844,"sourceCodeEnd":7880,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client.rs#L7844-L7880","documentation":"This `expect` panics when `tempfile::tempdir()` fails to create a temporary directory, aborting the test with 'home' at crates/tui/src/client.rs:7862. The test needs a scratch directory to point `CODEWHALE_HOME` at; tempfile returns `Err` when the OS cannot create it.","triggerScenarios":"Calling `tempfile::tempdir().expect(\"home\")` when `TMPDIR` points somewhere unwritable, the filesystem is full, sandboxed CI denies mkdtemp, or a `TMPDIR` override in the test environment is invalid.","commonSituations":"CI containers with read-only /tmp; `lock_test_env` or another guard set `TMPDIR` to a nonexistent path; disk quota exhaustion on long test runs leaving stale temp dirs.","solutions":["Inspect the underlying `io::Error` (`tempfile::tempdir().unwrap_err()`) to see the OS reason","Check `TMPDIR`/`TEMP` env vars for invalid or read-only values inside the test process","Free disk space or clean stale temp directories","Fall back to an explicit writable directory via `tempfile::Builder::new().tempdir_in(...)`"],"exampleFix":"// before\nlet home = tempfile::tempdir().expect(\"home\");\n// after\nlet home = tempfile::tempdir()\n    .unwrap_or_else(|e| panic!(\"home: failed to create temp dir: {e}\"));","handlingStrategy":"try-catch","validationCode":"// check env before creating\ndebug_assert!(std::env::var(\"TMPDIR\").map(|p| std::path::Path::new(&p).is_dir()).unwrap_or(true),\n    \"TMPDIR is not a directory\");","typeGuard":null,"tryCatchPattern":"let home = tempfile::tempdir()\n    .unwrap_or_else(|e| panic!(\"temp dir creation failed: {e}\"));","preventionTips":["Avoid tests overriding TMPDIR to invalid paths","Clean stale temp dirs in CI to prevent quota exhaustion","Use tempdir_in with a known-writable path in sandboxed environments"],"tags":["rust","filesystem","tempdir"],"backgroundTag":"temp-dir-creation-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}