{"record":{"id":"c865dbc0a2ab8ec3","repo":"Hmbown/CodeWhale","slug":"store-into-a-fresh-directory","errorCode":null,"errorMessage":"store into a fresh directory","messagePattern":"store into a fresh directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/release/src/check.rs","lineNumber":244,"sourceCode":"        assert_eq!(UpdateCheckCache::load(&path), Some(first));\n\n        // Overwriting in place must not leave the temp file behind.\n        let second = UpdateCheckCache {\n            checked_at_unix: 99,\n            latest_tag: None,\n        };\n        second.store(&path).expect(\"overwrite\");\n        assert_eq!(UpdateCheckCache::load(&path), Some(second));\n        assert!(!path.with_extension(\"json.tmp\").exists());\n    }\n\n    #[test]\n    fn store_creates_a_missing_home_directory() {\n        let dir = tempfile::tempdir().expect(\"tempdir\");\n        let path = cache_path_in(&dir.path().join(\"nested\").join(\"home\"));\n        UpdateCheckCache::now(Some(\"v1.0.0\".to_string()))\n            .store(&path)\n            .expect(\"store into a fresh directory\");\n        assert!(path.exists());\n    }\n\n    #[test]\n    fn a_corrupt_or_absent_cache_reads_as_none() {\n        let dir = tempfile::tempdir().expect(\"tempdir\");\n        let path = cache_path_in(dir.path());\n        assert_eq!(UpdateCheckCache::load(&path), None);\n        std::fs::write(&path, b\"{ not json\").expect(\"write junk\");\n        assert_eq!(UpdateCheckCache::load(&path), None);\n    }\n\n    #[test]\n    fn falsey_flag_values_do_not_count_as_set() {\n        for value in [\"\", \"0\", \"false\", \"FALSE\", \" no \", \"off\"] {\n            assert!(\n                !flag_value_is_truthy(value),\n                \"{value:?} should not read as set\"","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/release/src/check.rs#L226-L262","documentation":"Test panic from `.store(&path).expect(\"store into a fresh directory\")`: storing the update-check cache into a path whose parent directories (`nested/home`) do not exist yet failed. store is supposed to create_dir_all the parent before the temp-file write, so this failing means directory creation itself was refused or the subsequent write/rename failed.","triggerScenarios":"Calling UpdateCheckCache::store on cache_path_in(&home.join(\"nested\").join(\"home\")): panics if create_dir_all hits permission denied (read-only tempdir, restricted sandbox), the disk is full, or the temp-file write/rename within the freshly created directory fails.","commonSituations":"Deeply nested paths exceeding filesystem limits in unusual TMPDIRs; sandboxed CI blocking mkdir; read-only or quota'd temp filesystems; concurrent tests racing on the same temp path.","solutions":["Read the anyhow context (\"failed to create …\") to confirm whether create_dir_all or the write/rename step failed.","Verify the base tempdir is writable and the sandbox permits mkdir -p of nested paths.","Free disk space or fix permissions on the temp filesystem, then rerun the single test to confirm."],"exampleFix":"// before\nUpdateCheckCache::now(Some(\"v1.0.0\".to_string()))\n    .store(&path)\n    .expect(\"store into a fresh directory\");\n// after — pre-check the environment the test depends on\nassert!(dir.path().status().map(|m| m.permissions().readonly() == false).unwrap_or(false));\nUpdateCheckCache::now(Some(\"v1.0.0\".to_string()))\n    .store(&path)\n    .expect(\"store into a fresh directory\");","handlingStrategy":"validation","validationCode":"// mkdir -p the target parent up front so failures are attributable\nlet dir = path.parent().unwrap();\nstd::fs::create_dir_all(dir).expect(\"failed to create nested home directory\");","typeGuard":"fn can_create_nested_under(base: &Path) -> bool {\n    base.metadata().map(|m| !m.permissions().readonly()).unwrap_or(false)\n}","tryCatchPattern":"store_result.unwrap_or_else(|e| panic!(\"store into fresh dir failed: {e:#}\")); // context names the failing step","preventionTips":["Keep home-directory depth modest; deep nested paths hit path-length limits on some filesystems.","Confirm sandbox/CI policies permit recursive mkdir under the temp root.","Check the anyhow context chain first — it distinguishes mkdir failures from write/rename failures."],"tags":["rust","filesystem","mkdir","test-panic"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}