{"record":{"id":"1ea1ade3f59fa60a","repo":"Hmbown/CodeWhale","slug":"legacy-import-left-rejected-notes-unchanged-inspect-before","errorCode":null,"errorMessage":"legacy import left {} rejected notes unchanged; inspect before retry","messagePattern":"legacy import left (.+?) rejected notes unchanged; inspect before retry","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/native_memory.rs","lineNumber":520,"sourceCode":"            return Ok(false);\n        }\n        let meta = fs::symlink_metadata(path)?;\n        if meta.file_type().is_symlink() || meta.len() > 1024 * 1024 {\n            bail!(\"legacy import refused: symlink or size bound\");\n        }\n        let text = fs::read_to_string(path)?;\n        let scope = Self::owner_scope();\n        let access = Access::operator(vec![scope.clone()])?;\n        let mut store = self.open_structured()?;\n        let report = codewhale_memory::import::markdown(\n            &mut store,\n            &access,\n            &scope,\n            \"codewhale:legacy-memory\",\n            &text,\n        )?;\n        if !report.rejected.is_empty() {\n            bail!(\n                \"legacy import left {} rejected notes unchanged; inspect before retry\",\n                report.rejected.len()\n            );\n        }\n        Ok(report.created > 0)\n    }\n    pub fn export(&self) -> Result<String> {\n        let store = self.open_structured()?;\n        let owner = Access::operator(vec![Self::owner_scope()])?;\n        let scopes = store.local_scope_inventory(&owner)?;\n        let mut output = String::from(\n            \"# CodeWhale memory export\\n\\nNot an instruction file. This Markdown is not authoritative.\\n\",\n        );\n        for scope in scopes {\n            let access = Access::operator(vec![scope])?;\n            let mut after = None;\n            loop {\n                let batch = store.list(&access, after.as_deref(), 500)?;","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/native_memory.rs#L502-L538","documentation":"During import of notes from the legacy (pre-structured) memory store, some notes failed validation and were rejected by the structured store's note importer. Because a partial import would silently drop data, the function aborts with this error, leaving all notes unimported so the failure can be inspected before retrying. It is a deliberate fail-loud guard against data loss.","triggerScenarios":"Calling import_legacy when at least one legacy note fails the structured store's write/import validation (e.g. a note violates size limits, encoding, or scope rules), producing a non-empty report.rejected.","commonSituations":"Migrating an old ~/.codewhale-style memory file that contains notes no longer accepted by the current store format; corrupt or oversized legacy notes; schema changes between versions that tightened note validation.","solutions":["Inspect the legacy store contents to find the note(s) that fail validation (rejected count is in the message).","Fix or remove the offending legacy notes, then re-run import_legacy.","If upgrading across versions, check the changelog for tightened note validation rules and migrate notes accordingly.","Import into a fresh structured store location to rule out conflicts with existing data."],"exampleFix":"// before\nimport_legacy(&store)?; // aborts: legacy import left 3 rejected notes unchanged\n// after\n// prune or repair invalid legacy notes first, then retry\nlet report = import_legacy(&store)?;\nassert!(report.rejected.is_empty());","handlingStrategy":"validation","validationCode":"let report = store.dry_run_import_legacy(&legacy_notes)?;\nif !report.rejected.is_empty() {\n    eprintln!(\"fix {} rejected legacy notes before importing\", report.rejected.len());\n}","typeGuard":null,"tryCatchPattern":"match import_legacy(&store) {\n    Ok(_) => {},\n    Err(e) if e.to_string().contains(\"rejected notes unchanged\") => inspect_and_repair_legacy_notes(),\n    Err(e) => return Err(e),\n}","preventionTips":["Validate legacy note content (length, encoding, scope) before running the import.","Back up the legacy store before importing.","Test the import on a copy of the data first.","Check release notes for tightened note-validation rules before upgrading."],"tags":["memory","migration","import","data-integrity"],"backgroundTag":"schema-validation-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}