{"record":{"id":"f8e99cb874dd7f73","repo":"nexu-io/open-design","slug":"output-already-exists-pass-force-to-replace-i","errorCode":null,"errorMessage":"{output} already exists; pass --force to replace it","messagePattern":"(.+?) already exists; pass --force to replace it","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"warning","filePath":"skills/hatch-pet/scripts/derive_running_left_from_running_right.py","lineNumber":98,"sourceCode":"\n    run_dir = Path(args.run_dir).expanduser().resolve()\n    manifest_path = run_dir / \"imagegen-jobs.json\"\n    manifest = load_manifest(run_dir)\n    right_job = find_job(manifest, \"running-right\")\n    left_job = find_job(manifest, \"running-left\")\n\n    if right_job.get(\"status\") != \"complete\":\n        raise SystemExit(\"running-right must be complete before deriving running-left\")\n    mirror_policy = left_job.get(\"mirror_policy\")\n    if not isinstance(mirror_policy, dict) or mirror_policy.get(\"may_derive_from\") != \"running-right\":\n        raise SystemExit(\"running-left is not configured for conditional mirroring\")\n\n    source = run_dir / \"decoded\" / \"running-right.png\"\n    output = run_dir / \"decoded\" / \"running-left.png\"\n    if not source.is_file():\n        raise SystemExit(f\"running-right decoded strip not found: {source}\")\n    if output.exists() and not args.force:\n        raise SystemExit(f\"{output} already exists; pass --force to replace it\")\n\n    output.parent.mkdir(parents=True, exist_ok=True)\n    with Image.open(source) as image:\n        mirrored = ImageOps.mirror(image.convert(\"RGBA\"))\n        mirrored.save(output)\n\n    left_job[\"status\"] = \"complete\"\n    left_job[\"source_path\"] = manifest_relative(source, run_dir)\n    left_job[\"source_provenance\"] = \"deterministic-mirror\"\n    left_job[\"derived_from\"] = \"running-right\"\n    left_job[\"source_sha256\"] = file_sha256(source)\n    left_job[\"output_sha256\"] = file_sha256(output)\n    left_job[\"completed_at\"] = datetime.now(timezone.utc).isoformat()\n    left_job[\"metadata\"] = image_metadata(output)\n    left_job[\"mirror_decision\"] = {\n        \"approved\": True,\n        \"approved_at\": left_job[\"completed_at\"],\n        \"note\": args.decision_note.strip(),","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/hatch-pet/scripts/derive_running_left_from_running_right.py#L80-L116","documentation":"decoded/running-left.png already exists and --force was not passed. The guard prevents silently overwriting a previously derived and reviewed mirror, which would invalidate its recorded output_sha256 and lineage.","triggerScenarios":"Re-running derive_running_left_from_running_right.py after a prior successful derive, without --force, while decoded/running-left.png is still present.","commonSituations":"Iterating on the mirror; re-running the script in CI; a previous run left an output behind and the user re-invoked to refresh it.","solutions":["If the existing running-left.png is correct, do nothing — it is already derived.","If you genuinely need to re-derive, add --force to overwrite the existing output and refresh its hashes.","Before forcing, confirm the existing file is not a hand-edited PNG (it should be a byte-exact mirror of running-right)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from pathlib import Path\n\noutput = Path(\"<run_dir>\") / \"decoded\" / \"running-left.png\"\nextra = [\"--force\"] if output.exists() else []\n# then invoke derive_running_left_from_running_right.py with *extra","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check for an existing running-left.png before re-deriving; pass --force only when you intend to replace it.","Treat a prior output as authoritative unless running-right itself changed.","Avoid running derive twice in CI without --force or without clearing the output."],"tags":["hatch-pet","idempotency","overwrite-guard"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}