{"record":{"id":"badac317ae6acc80","repo":"github/spec-kit","slug":"command-rollback-found-an-unexpected-directory-at-badac3","errorCode":null,"errorMessage":"Command rollback found an unexpected directory at '{command_path}'","messagePattern":"Command rollback found an unexpected directory at '(.+?)'","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/specify_cli/extensions/_commands.py","lineNumber":2319,"sourceCode":"                    # Only perform destructive rollback if backup exists (meaning we\n                    # actually modified the extension). This avoids deleting a valid\n                    # installation when failure happened before changes were made.\n                    extension_dir = manager.extensions_dir / extension_id\n                    if backup_ext_dir.exists():\n                        if extension_dir.exists():\n                            shutil.rmtree(extension_dir)\n                        shutil.copytree(backup_ext_dir, extension_dir)\n\n                    # Remove any NEW command files created by failed install\n                    # (files that weren't in the original backup). Registration\n                    # writes before registry.add(), so start with the paths that\n                    # were absent at the destructive boundary instead of relying\n                    # only on a possibly missing new registry entry.\n                    for command_path in new_command_paths_absent_before_update:\n                        if command_path.is_symlink() or command_path.is_file():\n                            command_path.unlink()\n                        elif command_path.exists():\n                            raise RuntimeError(\n                                \"Command rollback found an unexpected directory \"\n                                f\"at '{command_path}'\"\n                            )\n                    new_registered_skills = []\n                    try:\n                        new_registry_entry = manager.registry.get(extension_id)\n                        if new_registry_entry is None or not isinstance(new_registry_entry, dict):\n                            new_registered_commands = {}\n                        else:\n                            new_registered_commands = new_registry_entry.get(\"registered_commands\", {})\n                            new_registered_skills = manager._valid_name_list(\n                                new_registry_entry.get(\"registered_skills\", [])\n                            )\n                        for agent_name, cmd_names in new_registered_commands.items():\n                            if agent_name not in registrar.AGENT_CONFIGS:\n                                continue\n                            agent_config = registrar.AGENT_CONFIGS[agent_name]\n                            commands_dir = _AgentReg._resolve_agent_dir(","sourceCodeStart":2301,"sourceCodeEnd":2337,"githubUrl":"https://github.com/github/spec-kit/blob/bf88c9f9a82fa370c7a7257aa2b3cf10b457b65c/src/specify_cli/extensions/_commands.py#L2301-L2337","documentation":"Error \"Command rollback found an unexpected directory at '{command_path}'\" thrown in github/spec-kit.","triggerScenarios":"Thrown at src/specify_cli/extensions/_commands.py:2319 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the unexpected directory at the command path so rollback can restore the file, then retry."],"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-15T22:17:37.221Z"}