{"record":{"id":"a429f9c3cfa4bf59","repo":"sinelaw/fresh","slug":"chunked-recovery-data-not-found","errorCode":null,"errorMessage":"Chunked recovery data not found","messagePattern":"Chunked recovery data not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/services/recovery/storage.rs","lineNumber":471,"sourceCode":"                original_len: chunk_meta.original_len,\n                content,\n            });\n        }\n\n        Ok(Some(ChunkedRecoveryData::new(\n            index.original_size,\n            index.final_size,\n            chunks,\n        )))\n    }\n\n    /// Reconstruct full content from chunked recovery and original file\n    ///\n    /// This reads the original file and applies the stored chunks to reconstruct\n    /// the full modified content.\n    pub fn reconstruct_from_chunks(&self, id: &str, original_file: &Path) -> io::Result<Vec<u8>> {\n        let chunked_data = self.read_chunked_content(id)?.ok_or_else(|| {\n            io::Error::new(io::ErrorKind::NotFound, \"Chunked recovery data not found\")\n        })?;\n\n        // Read original file\n        let original_content = fs::read(original_file)?;\n\n        tracing::debug!(\n            \"reconstruct_from_chunks: original_file={:?}, file_size_on_disk={}, expected_original_size={}\",\n            original_file,\n            original_content.len(),\n            chunked_data.original_size\n        );\n\n        // Verify original file size matches what we expected\n        if original_content.len() != chunked_data.original_size {\n            return Err(io::Error::new(\n                io::ErrorKind::InvalidData,\n                format!(\n                    \"Original file size mismatch: expected {}, got {}\",","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/services/recovery/storage.rs#L453-L489","documentation":"reconstruct_from_chunks calls read_chunked_content and requires Some(chunked_data); None means no chunked recovery data (chunk index) exists for the given id, so reconstruction cannot proceed. Thrown as io::ErrorKind::NotFound with this message to distinguish 'no data at all' from per-chunk file failures.","triggerScenarios":"reconstruct_from_chunks(id, original_file) invoked with an id that has no stored chunk index — wrong id, entry already consumed/deleted, or the recovery store directory differs from the write-time one.","commonSituations":"Recovery flows run after the entry was already recovered once and cleaned up; tests or scripts hardcoding ids; mixing recovery directories between profiles/machines.","solutions":["Confirm the id exists via list_entries before calling reconstruct_from_chunks.","Point the recovery storage at the correct directory that contains the chunked data.","Treat NotFound as 'nothing to recover' and fall back to the original file content instead of failing."],"exampleFix":"// before\nlet content = storage.reconstruct_from_chunks(&id, &original)?;\n// after\nlet content = match storage.reconstruct_from_chunks(&id, &original) {\n    Ok(c) => c,\n    Err(e) if e.kind() == io::ErrorKind::NotFound => fs::read(&original)?,\n    Err(e) => return Err(e),\n};","handlingStrategy":"fallback","validationCode":"if !storage.exists_chunked(&id) { return Ok(fs::read(original_file)?); }","typeGuard":"fn has_recovery_data(storage: &RecoveryStorage, id: &str) -> bool { storage.read_chunked_content(id).map(|o| o.is_some()).unwrap_or(false) }","tryCatchPattern":"let content = match storage.reconstruct_from_chunks(&id, &original) {\n    Ok(c) => c,\n    Err(e) if e.kind() == io::ErrorKind::NotFound => fs::read(&original)?,\n    Err(e) => return Err(e.into()),\n};","preventionTips":["Look up valid ids via list_entries before reconstruction; never hardcode ids","Fall back to the untouched original file when no recovery data exists","Point all sessions at the same recovery storage root"],"tags":["recovery","io","not-found","chunks"],"backgroundTag":"resource-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"}