{"record":{"id":"991bb24da0974074","repo":"bmad-code-org/BMAD-METHOD","slug":"generation-collision-or-corruption-at-destination","errorCode":null,"errorMessage":"generation collision or corruption at {destination}","messagePattern":"generation collision or corruption at (.+?)","errorType":"exception","errorClass":"RenderError","httpStatus":null,"severity":"critical","filePath":"src/scripts/render_skill.py","lineNumber":277,"sourceCode":"        if target not in source_names:\n            raise RenderError(f\"snapshot reference targets undeclared source: {target}\")\n        return str(destination / target)\n\n    rendered: dict[str, str] = {}\n    for name, content in sources.items():\n        # Inserted paths and customization prose are never scanned as source tokens.\n        rendered[name] = token_pattern.sub(replace, content)\n    return rendered\n\n\ndef _verify_existing(destination: Path, manifest: dict[str, Any]) -> None:\n    manifest_path = destination / \"manifest.json\"\n    try:\n        existing = json.loads(manifest_path.read_text(encoding=\"utf-8\"))\n    except (OSError, UnicodeError, json.JSONDecodeError) as error:\n        raise RenderError(f\"corrupt existing generation {destination}: {error}\") from error\n    if existing != manifest:\n        raise RenderError(f\"generation collision or corruption at {destination}\")\n    expected_files = set(manifest[\"outputs\"]) | {\"manifest.json\"}\n    actual_files = {\n        path.relative_to(destination).as_posix()\n        for path in destination.rglob(\"*\")\n        if path.is_file()\n    }\n    if actual_files != expected_files:\n        raise RenderError(f\"generation contains unexpected or missing files: {destination}\")\n    for name, expected_hash in manifest[\"outputs\"].items():\n        try:\n            actual_hash = _hash_bytes((destination / name).read_bytes())\n        except OSError as error:\n            raise RenderError(f\"failed to verify {destination / name}: {error}\") from error\n        if actual_hash != expected_hash:\n            raise RenderError(f\"generation output hash mismatch: {destination / name}\")\n\n\ndef _publish(destination: Path, outputs: dict[str, bytes], manifest: dict[str, Any]) -> None:","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/bmad-code-org/BMAD-METHOD/blob/b70486b9bdcb0a404d329e2a763b57964e7f1360/src/scripts/render_skill.py#L259-L295","documentation":"The existing manifest.json parsed successfully but its content differs from the freshly computed manifest. Because the destination path is derived from a hash of all inputs (source hashes, resolved config values, renderer SHA-256), a content mismatch means two different input sets claimed the same location -- external tampering, a partial renderer upgrade, or an astronomically unlikely hash collision. The renderer refuses to overwrite.","triggerScenarios":"A generation directory exists at the computed hash, but its recorded inputs/outputs differ from the current run -- e.g. files under the generation dir were modified, or the renderer source changed such that identity no longer matches.","commonSituations":"Manual modification of a generated directory; a renderer upgrade leaving stale generations; symlink/permission tricks altering recorded inputs.","solutions":["If the existing directory was hand-modified, delete it and re-run render.","If caused by a renderer upgrade, remove stale generations and regenerate.","Commit generations to VCS unmodified so divergence is visible in diffs."],"exampleFix":"# before: a mismatched generation blocks re-render\n# after\nrm -rf _bmad/render/<skill>/<slug>-<hash>\n# then re-run the renderer","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from render_skill import render, RenderError\n\ntry:\n    entry = render(project_root, skill_dir)\nexcept RenderError as e:\n    if \"generation collision or corruption\" in str(e):\n        # a prior generation diverged -- remove it and regenerate\n        ...\n    raise","preventionTips":["Treat generated dirs as immutable.","After a renderer upgrade, clear stale generations before re-rendering.","Commit generations unmodified so divergence is detectable."],"tags":["python","manifest","corruption","idempotency","hash"],"backgroundTag":null,"analyzedSha":"b70486b9bdcb0a404d329e2a763b57964e7f1360","analyzedAt":"2026-08-13T01:21:12.247Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}