{"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":"anyhow::Error","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/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/skills/mutation.rs#L705-L741","documentation":"Raised in import_external when the destination directory already exists but its computed package digest differs from the expected digest supplied by the caller. This is a conflict guard: the existing owned skill is not byte-identical to the package being imported, and the current conflict policy does not authorize overwriting it.","triggerScenarios":"Thrown at crates/tui/src/skills/mutation.rs:723 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a conflict policy that allows replacing (which backs up the existing skill first)","Remove the existing destination skill and retry the import","Verify the expected digest passed in matches the package you actually want; a stale digest causes a spurious conflict"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}