{"record":{"id":"0e3f0d1d47c54d98","repo":"abhigyanpatwari/GitNexus","slug":"overlay-apply-failed-and-all-replacements-were-rol","errorCode":null,"errorMessage":"overlay apply failed and all replacements were rolled back","messagePattern":"overlay apply failed and all replacements were rolled back","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/promotion_apply.py","lineNumber":878,"sourceCode":"                    rollback_failures.append(f\"{replacement['target']}: {type(rollback_exc).__name__}: {rollback_exc}\")\n            else:\n                if not rollback_exchange_is_valid(replacement, temporary_identity, displaced_state):\n                    rollback_failures.append(f\"{replacement['target']}: rollback parity check failed\")\n        if rollback_failures:\n            preserve_backups = True\n            recovery = _write_recovery_artifact(\n                root_descriptor,\n                repo_root,\n                failure=exc,\n                rollback_failures=rollback_failures,\n                replacements=replacements,\n                transaction_state=\"rollback-incomplete\",\n            )\n            raise RuntimeError(f\"overlay apply failed and rollback was incomplete; recovery: {recovery}\") from exc\n        rollback_complete = True\n        if isinstance(exc, (KeyboardInterrupt, SystemExit)):\n            raise\n        raise RuntimeError(\"overlay apply failed and all replacements were rolled back\") from exc\n    finally:\n        active_failure = sys.exc_info()[1]\n        try:\n            if not preserve_backups:\n                cleanup_failures: list[str] = []\n                cleanup_exception: BaseException | None = None\n                for replacement in replacements:\n                    for temporary in (replacement[\"candidate\"], replacement[\"backup\"]):\n                        if temporary is None:\n                            continue\n                        try:\n                            _unlink_temporary(replacement[\"parent_descriptor\"], temporary)\n                        except BaseException as cleanup_exc:\n                            cleanup_exception = cleanup_exc\n                            cleanup_failures.append(\n                                f\"{replacement['target']}:{temporary}: {type(cleanup_exc).__name__}: {cleanup_exc}\"\n                            )\n                            break","sourceCodeStart":860,"sourceCodeEnd":896,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/promotion_apply.py#L860-L896","documentation":"Thrown from the `except` block of `apply_promoted_overlay` when the apply failed but every completed replacement was rolled back cleanly (`rollback_failures` empty, `rollback_complete=True`). The working tree should be back to its pre-apply state; this is the 'safe' failure outcome — no recovery artifact is written.","triggerScenarios":"Any pre-publication or mid-apply failure (drift at 409/410, staging error, parity failure) where the rollback loop successfully re-swapped all completed targets and verified each displaced state. The exception is re-raised (preserving the original cause via `from exc`) so the caller knows the apply did not publish.","commonSituations":"Transient drift (409/410) that the rollback fully reversed; a staging error before any exchange completed; KeyboardInterrupt during apply that was caught and rolled back; a single-target parity failure (411) where every earlier swap rolled back.","solutions":["Inspect the chained `__cause__` exception to learn the original failure (drift, parity, staging).","Confirm the tree is clean: `git status --porcelain` and compare `destination_base_digests(overlay)` to your prior capture.","Re-capture `expected_target_bases`/`expected_digest` and retry the apply once the root cause (concurrent writer, etc.) is resolved.","No recovery artifact cleanup is needed because rollback was complete."],"exampleFix":"try:\n    apply_promoted_overlay(overlay, expected_target_bases=bases)\nexcept RuntimeError as exc:\n    # rollback completed cleanly; inspect original cause\n    print('apply rolled back:', exc.__cause__)\n    # re-capture and retry after silencing the concurrent writer\n    bases = destination_base_digests(overlay)\n    apply_promoted_overlay(overlay, expected_target_bases=bases)","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    apply_promoted_overlay(overlay, expected_target_bases=bases)\nexcept RuntimeError as exc:\n    if \"all replacements were rolled back\" in str(exc):\n        # safe state — inspect the original cause, re-capture, retry\n        original = exc.__cause__\n        print(\"apply aborted cleanly; original cause:\", original)\n        bases = destination_base_digests(overlay)\n        apply_promoted_overlay(overlay, expected_target_bases=bases)\n    else:\n        raise","preventionTips":["This is the safe failure outcome — check `git status` is clean before retrying.","Inspect `exc.__cause__` to learn the original failure and fix it before retry.","Re-capture `expected_target_bases`/`expected_digest` after a rollback; never reuse the stale values."],"tags":["integrity","rollback","transaction","recovered"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}