{"record":{"id":"edc089a76d2ed4af","repo":"Hmbown/CodeWhale","slug":"destination-already-exists-with-different-conte","errorCode":null,"errorMessage":"destination {} already exists with different content","messagePattern":"destination (.+?) already exists with different content","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/skills/mutation.rs","lineNumber":723,"sourceCode":"        ),\n    };\n\n    let dest_exists = validate_owned_child(&skills_dir, &dest, false)?;\n    if dest_exists {\n        let existing = package_digest::compute_package_digest(&dest).ok();\n        if existing.as_deref() == Some(expected_digest.as_str()) {\n            return Ok(SkillMutationReceipt {\n                action: SkillActionKind::Import,\n                name: source_id.canonical_name.clone(),\n                scope: target.as_skill_scope(),\n                safe_target_path: safe_display_path(&dest, Some(ctx.workspace), ctx.home),\n                before_digest: before,\n                after_digest: existing,\n                outcome: SkillMutationOutcome::AlreadyPresent,\n            });\n        }\n        if conflict_policy == ConflictPolicy::Reject {\n            bail!(\n                \"destination {} already exists with different content\",\n                dest.display()\n            );\n        }\n    }\n\n    // Re-verify source digest immediately before copy (TOCTOU).\n    let _ = verify_expected_digest(&source_path, Some(&expected_digest))?;\n    validate_owned_target_chain(anchor, &skills_dir, true)?;\n\n    let staging = skills_dir.join(format!(\"{dest_segment}.tmp\"));\n    if validate_owned_child(&skills_dir, &staging, false)? {\n        fs::remove_dir_all(&staging)\n            .with_context(|| format!(\"failed to clean stale staging dir {}\", staging.display()))?;\n    }\n    copy_skill_package(&source_path, &staging)?;\n    validate_owned_target_chain(anchor, &skills_dir, true)?;\n    validate_owned_child(&skills_dir, &staging, true)?;","sourceCodeStart":705,"sourceCodeEnd":741,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/skills/mutation.rs#L705-L741","documentation":"When the destination package already exists in the owned scope but its content digest differs from the imported source, `import_external` honors the configured `ConflictPolicy`. With `ConflictPolicy::Reject` the operation fails instead of overwriting existing content.","triggerScenarios":"Calling `import_external` with `conflict_policy == ConflictPolicy::Reject` while `dest` already exists and its package digest differs from `expected_digest` (the pre-copy source digest).","commonSituations":"Editing the skill in its external source after a previous import, then re-importing under Reject; concurrent edits to the owned copy; importing an older/newer version of the same skill over a modified owned copy.","solutions":["Pass `ConflictPolicy::Replace` to intentionally replace the differing destination.","Delete or manually merge the existing destination package, then re-run the import with Reject.","Update the external source to match if the owned copy is the authoritative version.","Diff `dest` against the source to decide which content you actually want before re-importing."],"exampleFix":"// before\nmutation.execute_sync(Mutation::ImportExternal { source_id, target, conflict_policy: ConflictPolicy::Reject })?;\n// after\nmutation.execute_sync(Mutation::ImportExternal { source_id, target, conflict_policy: ConflictPolicy::Replace })?;","handlingStrategy":"try-catch","validationCode":"if owned_dest_exists && owned_dest_digest != expected_digest && conflict_policy == ConflictPolicy::Reject {\n    // resolve the conflict manually or switch to Replace before calling import\n}","typeGuard":null,"tryCatchPattern":"match err.downcast_ref::<String>() {\n    Some(msg) if msg.starts_with(\"destination \") && msg.ends_with(\"already exists with different content\") => {\n        // retry with ConflictPolicy::Replace or merge manually\n    }\n    _ => return Err(err),\n}","preventionTips":["Decide a conflict policy explicitly before importing.","Diff the existing destination against the source when digests differ.","Avoid editing owned imported copies in place; edit the external source and re-import."],"tags":["skills","conflict","import"],"backgroundTag":"file-already-exists","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"}