Hmbown/CodeWhale · error

seed corrupt record

Error message

seed corrupt record

What it means

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).

Solutions

  1. Confirm the temp directory is writable (`touch $TMPDIR/probe`)
  2. Check disk space and quota on the temp volume
  3. Exclude the test temp dir from security software interference
  4. If the path helper changed, verify `record_path_in` still points inside the tempdir

Example fix

// before
std::fs::write(&path, b"{ not json").expect("seed corrupt record");
// after (diagnose)
std::fs::write(&path, b"{ not json")
    .unwrap_or_else(|e| panic!("seed corrupt record: {e} (path={})", path.display()));
Defensive patterns

Strategy: try-catch

Validate before calling

// rust: check writability before seeding
assert!(path.parent().map(|p| p.is_dir()).unwrap_or(false), "record parent missing");

Try / catch

// rust
match std::fs::write(&path, b"{ not json") {
    Ok(_) => { /* proceed */ }
    Err(e) => panic!("seed corrupt record failed: {e} (path={})", path.display()),
}

Prevention

When it happens

Trigger: `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.

Common situations: Read-only temp mounts in CI, quota limits, antivirus/EDR blocking writes of suspicious content, tmpfs cleaned concurrently by another job.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/a5fb109e8047f318. Report an issue: GitHub.

Appendix: source

Thrown at crates/release/src/launch.rs:275

    // Keeping the high-water mark instead would swallow the hint when the user
    // returns to the newer build.
    #[test]
    fn a_downgrade_rewrites_the_record_so_the_return_trip_still_hints() {
        let home = tempfile::tempdir().expect("tempdir");
        record_launch(home.path(), "0.9.11");
        assert_eq!(record_launch(home.path(), "0.9.10").change, None);
        assert_eq!(
            LastLaunch::load(&record_path_in(home.path())).map(|r| r.version),
            Some("0.9.10".to_string())
        );
        assert!(record_launch(home.path(), "0.9.11").change.is_some());
    }

    #[test]
    fn a_corrupt_record_is_replaced_rather_than_reported() {
        let home = tempfile::tempdir().expect("tempdir");
        let path = record_path_in(home.path());
        std::fs::write(&path, b"{ not json").expect("seed corrupt record");
        assert_eq!(record_launch(home.path(), "0.9.11").change, None);
        assert_eq!(
            LastLaunch::load(&path).map(|r| r.version),
            Some("0.9.11".to_string())
        );
    }

    #[test]
    fn store_replaces_an_existing_record() {
        let home = tempfile::tempdir().expect("tempdir");
        let path = record_path_in(home.path());
        LastLaunch {
            version: "0.9.10".to_string(),
        }
        .store(&path)
        .expect("seed record");
        LastLaunch {
            version: "0.9.11".to_string(),

View on GitHub (pinned to 433685b202)