{"record":{"id":"0c285b3697bf169b","repo":"sinelaw/fresh","slug":"chunk-content-not-found","errorCode":null,"errorMessage":"Chunk content not found","messagePattern":"Chunk content not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/services/recovery/mod.rs","lineNumber":359,"sourceCode":"                    });\n                }\n\n                if !original_path.exists() {\n                    return Ok(RecoveryResult::Corrupted {\n                        id: entry.id.clone(),\n                        reason: format!(\n                            \"Original file not found: {}. Recovery requires the original file.\",\n                            original_path.display()\n                        ),\n                    });\n                }\n\n                // Load chunks and return them for direct application\n                let chunked_data =\n                    self.storage\n                        .read_chunked_content(&entry.id)?\n                        .ok_or_else(|| {\n                            io::Error::new(io::ErrorKind::NotFound, \"Chunk content not found\")\n                        })?;\n\n                return Ok(RecoveryResult::RecoveredChunks {\n                    original_path: original_path.clone(),\n                    chunks: chunked_data.chunks,\n                });\n            } else {\n                return Ok(RecoveryResult::Corrupted {\n                    id: entry.id.clone(),\n                    reason: \"Recovery entry requires original file but path is not set\".to_string(),\n                });\n            }\n        }\n\n        // New buffer or small file - chunk contains full content\n        // For file-backed small files, check if the original was modified on disk\n        if entry.metadata.original_path.is_some() && entry.original_file_modified() {\n            return Ok(RecoveryResult::OriginalFileModified {","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/services/recovery/mod.rs#L341-L377","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Run the recovery entry listing (list_entries) first and only call load_recovery on entries whose chunk files still exist.","Check that the recovery storage directory path is the same one used when the entry was created (env/config mismatch)."],"exampleFix":"// before\nlet result = recovery.load_recovery(&entry)?;\n// after\nmatch recovery.load_recovery(&entry) {\n    Ok(result) => apply(result),\n    Err(e) if e.kind() == io::ErrorKind::NotFound => {\n        eprintln!(\"recovery data missing, skipping: {e}\");\n        recovery.remove_entry(&entry.id)?;\n    }\n    Err(e) => return Err(e),\n}","handlingStrategy":"try-catch","validationCode":"let entries = recovery.list_entries()?;\nlet recoverable: Vec<_> = entries.into_iter().filter(|e| recovery.chunked_data_exists(&e.id)).collect();","typeGuard":"fn is_recoverable(entry: &RecoveryEntry) -> bool { entry.is_chunked && recovery.chunked_data_exists(&entry.id) }","tryCatchPattern":"match recovery.load_recovery(&entry) {\n    Ok(r) => apply(r),\n    Err(e) if e.kind() == io::ErrorKind::NotFound => cleanup_stale_entry(&entry),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Write chunk data before publishing entry metadata (atomic publish order)","Never hand-delete files inside the recovery directory; use the provided cleanup API","Keep the recovery storage path stable across sessions/config changes"],"tags":["recovery","io","not-found"],"backgroundTag":"file-not-found","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}