{"record":{"id":"883ac74a0578fd1b","repo":"github/spec-kit","slug":"failed-to-stage-prior-workflow-move-exc-faile","errorCode":null,"errorMessage":"Failed to stage prior workflow ({move_exc}); failed to restore it from {backup_file} ({restore_exc}). The prior workflow remains at {backup_file}.","messagePattern":"Failed to stage prior workflow \\((.+?)\\); failed to restore it from (.+?) \\((.+?)\\)\\. The prior workflow remains at (.+?)\\.","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"src/specify_cli/workflows/_commands.py","lineNumber":776,"sourceCode":"        finally:\n            os.close(fd)\n        backup_file = Path(backup_name)\n        try:\n            os.replace(dest_file, backup_file)\n        except BaseException as move_exc:\n            backup_state = None\n            try:\n                backup_state = backup_file.stat(follow_symlinks=False)\n            except OSError:\n                pass\n            if (\n                backup_state is not None\n                and os.path.samestat(dest_state, backup_state)\n            ):\n                try:\n                    os.replace(backup_file, dest_file)\n                except OSError as restore_exc:\n                    raise OSError(\n                        f\"Failed to stage prior workflow ({move_exc}); failed \"\n                        f\"to restore it from {backup_file} ({restore_exc}). \"\n                        f\"The prior workflow remains at {backup_file}.\"\n                    ) from restore_exc\n            elif (\n                backup_state is not None\n                and os.path.samestat(placeholder_state, backup_state)\n            ):\n                try:\n                    backup_file.unlink(missing_ok=True)\n                except OSError:\n                    pass\n            raise\n        try:\n            if isinstance(staged_file, _StagedWorkflowFile):\n                staged_file.verify_path()\n                # Windows cannot replace an open file. Verify through the\n                # exclusive descriptor, then close immediately before rename.","sourceCodeStart":758,"sourceCodeEnd":794,"githubUrl":"https://github.com/github/spec-kit/blob/bf88c9f9a82fa370c7a7257aa2b3cf10b457b65c/src/specify_cli/workflows/_commands.py#L758-L794","documentation":"Error \"Failed to stage prior workflow ({move_exc}); failed to restore it from {backup_file} ({restore_exc}). The prior workflow remains at {backup_file}.\" thrown in github/spec-kit.","triggerScenarios":"Thrown at src/specify_cli/workflows/_commands.py:776 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Manually restore the prior workflow from the reported backup file, then retry the operation."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bf88c9f9a82fa370c7a7257aa2b3cf10b457b65c","analyzedAt":"2026-08-14T19:43:37.150Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}