can1357/oh-my-pi · error · GitCommandError

GitCommandError: workspace reset command failed (nonzero exi

Error message

GitCommandError: workspace reset command failed (nonzero exit)

What it means

In ensure_release_workspace(), after detaching, the release workspace runs its reset/config command list (including `git config user.email/user.name`) via _safe_run; any nonzero exit raises GitCommandError so a half-configured release workspace is never returned.

Source

Thrown at python/robomp/src/sandbox.py:1088

                    repo_dir=repo_dir,
                )

            _share_git_metadata_with_slots(repo_dir, slot_uid)
            _provision_runtime_dirs(ws_root)
            _chown_workspace(ws_root, slot_uid)
            slot_git_kwargs = _slot_subprocess_kwargs(slot_uid)
            slot_git_env = _git_env_for_repo(repo_dir)
            commands = (
                ["git", "checkout", "-B", default_branch, f"origin/{default_branch}"],
                ["git", "reset", "--hard", f"origin/{default_branch}"],
                ["git", "clean", "-fd"],
                ["git", "config", "user.email", author_email],
                ["git", "config", "user.name", author_name],
            )
            for command in commands:
                proc = _safe_run(command, cwd=repo_dir, env=slot_git_env, **slot_git_kwargs)
                if proc.returncode != 0:
                    raise GitCommandError(command, proc.returncode, proc.stdout, proc.stderr)
            _share_git_metadata_with_slots(repo_dir, slot_uid)
            workspace = Workspace(
                root=ws_root,
                repo_dir=repo_dir,
                session_dir=session_dir,
                context_dir=context_dir,
                artifacts_dir=artifacts_dir,
                branch=default_branch,
                repo_full_name=repo,
                issue_number="release",
            )
            self._populate_natives_cache(workspace, slot_uid=slot_uid)
            return workspace

    def _populate_natives_cache(self, workspace: Workspace, *, slot_uid: int | None = None) -> None:
        """Try to hardlink cached pi-natives artifacts into the worktree.

        Best-effort: any failure (no cache configured, non-git worktree,

View on GitHub (pinned to 9690622007)

Solutions

  1. Read GitCommandError.stderr for the failing command (the cmd is stored on the exception).
  2. Run `robomp cleanup owner/repo#release` (remove_workspace) to delete the poisoned release workspace, then retry.
  3. Remove any stale .git/index.lock inside the release worktree if stderr mentions it.
  4. Check /data volume writability and free space before retrying.
Defensive patterns

Strategy: try-catch

Validate before calling

if not (repo_dir / '.git').exists():
    raise RuntimeError('release worktree missing; run robomp cleanup first')

Type guard

def is_git_command_error(exc: BaseException) -> bool:
    return isinstance(exc, GitCommandError)

Try / catch

try:
    ws = manager.ensure_release_workspace(repo=repo, tag=tag)
except GitCommandError as e:
    manager.remove_workspace(repo=repo, number='release')  # reset poisoned workspace
    raise

Prevention

When it happens

Trigger: Calling ensure_release_workspace() when any command in the reset list fails in repo_dir — checkout/reset against a dirty or locked worktree, config write failure, or missing git.

Common situations: Leftover untracked/locked files in the release worktree from a previously failed run; stale index.lock after a container crash; read-only or full /data volume; slot git env misconfiguration.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/71c257465b8a2735. Report an issue: GitHub.