sinelaw/fresh · error

Chunk content not found

Error message

Chunk content not found

What it means

load_recovery found a recovery entry whose metadata says it stores chunked content (multi-chunk recovery data), but storage.read_chunked_content returned None — the chunked data file for that entry id does not exist. The editor throws this instead of silently returning an empty recovery, since recovery data is expected to be self-consistent once the entry metadata exists.

Solutions

  1. Recreate or restore the missing chunked content (chunk index) file for the entry id, or delete the stale recovery entry so it is no longer listed.
  2. Run the recovery entry listing (list_entries) first and only call load_recovery on entries whose chunk files still exist.
  3. Check that the recovery storage directory path is the same one used when the entry was created (env/config mismatch).

Example fix

// before
let result = recovery.load_recovery(&entry)?;
// after
match recovery.load_recovery(&entry) {
    Ok(result) => apply(result),
    Err(e) if e.kind() == io::ErrorKind::NotFound => {
        eprintln!("recovery data missing, skipping: {e}");
        recovery.remove_entry(&entry.id)?;
    }
    Err(e) => return Err(e),
}
Defensive patterns

Strategy: try-catch

Validate before calling

let entries = recovery.list_entries()?;
let recoverable: Vec<_> = entries.into_iter().filter(|e| recovery.chunked_data_exists(&e.id)).collect();

Type guard

fn is_recoverable(entry: &RecoveryEntry) -> bool { entry.is_chunked && recovery.chunked_data_exists(&entry.id) }

Try / catch

match recovery.load_recovery(&entry) {
    Ok(r) => apply(r),
    Err(e) if e.kind() == io::ErrorKind::NotFound => cleanup_stale_entry(&entry),
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling load_recovery on an entry whose metadata marks it as chunked while read_chunked_content(id) yields None — e.g. the chunk index file was deleted, the recovery directory was partially cleaned, or the entry id does not match any stored chunk index.

Common situations: Manual cleanup of the recovery directory, an interrupted write that persisted metadata but not the chunk index, or resuming a session on another machine where the recovery store was not synced.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13). Data as JSON: /api/errors/0c285b3697bf169b. Report an issue: GitHub.

Appendix: source

Thrown at crates/fresh-editor/src/services/recovery/mod.rs:359

                    });
                }

                if !original_path.exists() {
                    return Ok(RecoveryResult::Corrupted {
                        id: entry.id.clone(),
                        reason: format!(
                            "Original file not found: {}. Recovery requires the original file.",
                            original_path.display()
                        ),
                    });
                }

                // Load chunks and return them for direct application
                let chunked_data =
                    self.storage
                        .read_chunked_content(&entry.id)?
                        .ok_or_else(|| {
                            io::Error::new(io::ErrorKind::NotFound, "Chunk content not found")
                        })?;

                return Ok(RecoveryResult::RecoveredChunks {
                    original_path: original_path.clone(),
                    chunks: chunked_data.chunks,
                });
            } else {
                return Ok(RecoveryResult::Corrupted {
                    id: entry.id.clone(),
                    reason: "Recovery entry requires original file but path is not set".to_string(),
                });
            }
        }

        // New buffer or small file - chunk contains full content
        // For file-backed small files, check if the original was modified on disk
        if entry.metadata.original_path.is_some() && entry.original_file_modified() {
            return Ok(RecoveryResult::OriginalFileModified {

View on GitHub (pinned to 67894ca546)