{"record":{"id":"a5fb109e8047f318","repo":"Hmbown/CodeWhale","slug":"seed-corrupt-record","errorCode":null,"errorMessage":"seed corrupt record","messagePattern":"seed corrupt record","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/release/src/launch.rs","lineNumber":275,"sourceCode":"    // Keeping the high-water mark instead would swallow the hint when the user\n    // returns to the newer build.\n    #[test]\n    fn a_downgrade_rewrites_the_record_so_the_return_trip_still_hints() {\n        let home = tempfile::tempdir().expect(\"tempdir\");\n        record_launch(home.path(), \"0.9.11\");\n        assert_eq!(record_launch(home.path(), \"0.9.10\").change, None);\n        assert_eq!(\n            LastLaunch::load(&record_path_in(home.path())).map(|r| r.version),\n            Some(\"0.9.10\".to_string())\n        );\n        assert!(record_launch(home.path(), \"0.9.11\").change.is_some());\n    }\n\n    #[test]\n    fn a_corrupt_record_is_replaced_rather_than_reported() {\n        let home = tempfile::tempdir().expect(\"tempdir\");\n        let path = record_path_in(home.path());\n        std::fs::write(&path, b\"{ not json\").expect(\"seed corrupt record\");\n        assert_eq!(record_launch(home.path(), \"0.9.11\").change, None);\n        assert_eq!(\n            LastLaunch::load(&path).map(|r| r.version),\n            Some(\"0.9.11\".to_string())\n        );\n    }\n\n    #[test]\n    fn store_replaces_an_existing_record() {\n        let home = tempfile::tempdir().expect(\"tempdir\");\n        let path = record_path_in(home.path());\n        LastLaunch {\n            version: \"0.9.10\".to_string(),\n        }\n        .store(&path)\n        .expect(\"seed record\");\n        LastLaunch {\n            version: \"0.9.11\".to_string(),","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/release/src/launch.rs#L257-L293","documentation":"Panic from `std::fs::write(&path, b\"{ not json\").expect(\"seed corrupt record\")`. The test deliberately writes malformed JSON to the launch record and expects the write to succeed; the expect fires when the file cannot be written (bad path, permissions, or the earlier tempdir/parent path vanished).","triggerScenarios":"`record_path_in(home.path())` resolves to a location the test process cannot write to, the parent directory was removed, the disk is full, or permissions deny the write. Only reachable in the test after tempdir succeeds.","commonSituations":"Read-only temp mounts in CI, quota limits, antivirus/EDR blocking writes of suspicious content, tmpfs cleaned concurrently by another job.","solutions":["Confirm the temp directory is writable (`touch $TMPDIR/probe`)","Check disk space and quota on the temp volume","Exclude the test temp dir from security software interference","If the path helper changed, verify `record_path_in` still points inside the tempdir"],"exampleFix":"// before\nstd::fs::write(&path, b\"{ not json\").expect(\"seed corrupt record\");\n// after (diagnose)\nstd::fs::write(&path, b\"{ not json\")\n    .unwrap_or_else(|e| panic!(\"seed corrupt record: {e} (path={})\", path.display()));","handlingStrategy":"try-catch","validationCode":"// rust: check writability before seeding\nassert!(path.parent().map(|p| p.is_dir()).unwrap_or(false), \"record parent missing\");","typeGuard":null,"tryCatchPattern":"// rust\nmatch std::fs::write(&path, b\"{ not json\") {\n    Ok(_) => { /* proceed */ }\n    Err(e) => panic!(\"seed corrupt record failed: {e} (path={})\", path.display()),\n}","preventionTips":["Confirm tempdir is writable before writing test fixtures","Exclude test temp dirs from antivirus/EDR scanning","Fail fast with the path in the message to diagnose quickly"],"tags":["file-write","test-environment","filesystem","rust"],"backgroundTag":"file-write-failed","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"}