Yeachan-Heo/oh-my-codex · error · Error
workspace_status_failed
workspace_status_failed
Error message
workspace_status_failed:${cwd} What it means
Thrown when `git status --porcelain --untracked-files=all` in the given cwd exits non-zero with empty stderr, so the library cannot read the workspace cleanliness. readWorkspaceStatusLines backs cleanliness assertions like assertCleanLeaderWorkspaceForWorkerWorktrees.
Source
Thrown at src/team/worktree.ts:144
encoding: 'utf-8',
windowsHide: true,
});
if (result.status !== 0) {
const stderr = (result.stderr || '').trim();
throw new Error(stderr || `worktree_status_failed:${worktreePath}`);
}
return (result.stdout || '').trim() !== '';
}
export function readWorkspaceStatusLines(cwd: string): string[] {
const result = spawnSync('git', ['status', '--porcelain', '--untracked-files=all'], {
cwd,
encoding: 'utf-8',
windowsHide: true,
});
if (result.status !== 0) {
const stderr = (result.stderr || '').trim();
throw new Error(stderr || `workspace_status_failed:${cwd}`);
}
return (result.stdout || '')
.split(/\r?\n/)
.map((line) => line.trimEnd())
.filter(Boolean);
}
export function assertCleanLeaderWorkspaceForWorkerWorktrees(cwd: string): void {
const lines = readWorkspaceStatusLines(cwd);
if (lines.length === 0) return;
const preview = lines.slice(0, 8).join(' | ');
throw new Error(
`leader_workspace_dirty_for_worktrees:${resolve(cwd)}:${preview}:commit_or_stash_before_omx_team`,
);
}
function listWorktrees(repoRoot: string): GitWorktreeEntry[] {
const raw = readGit(repoRoot, ['worktree', 'list', '--porcelain']);View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Confirm cwd is the repository root and is a valid git repo (`git rev-parse --show-toplevel` works there)
- For 'dubious ownership' errors set `git config --global --add safe.directory <path>`
- Repair the index if corrupt: `rm -f .git/index && git reset` (staged state is recoverable from HEAD)
- Ensure the process has read access to .git and that git is on PATH
Example fix
# before: dubious ownership in container causes status to fail
# after:
git config --global --add safe.directory /workspace
# or in code: spawnSync('git',['config','--global','--add','safe.directory',repoRoot]) Defensive patterns
Strategy: validation
Validate before calling
function isUsableGitRepo(cwd: string): boolean {
const r = spawnSync('git', ['rev-parse','--is-inside-work-tree'], { cwd, encoding: 'utf-8' });
if (r.status !== 0) return false;
const safe = spawnSync('git', ['config','--get','safe.directory'], { encoding: 'utf-8' });
return true;
} Try / catch
catch (e) { if (String(e?.message).startsWith('workspace_status_failed:')) { /* surface 'git not usable in cwd' to user, check PATH and safe.directory */ } else throw e; } Prevention
- Always pass the repo root, not a subdirectory, to workspace-cleanliness APIs
- Configure safe.directory when running in containers/CI with different ownership
- Test `git status` works in the target cwd during environment setup
When it happens
Trigger: Calling assertCleanLeaderWorkspaceForWorkerWorktrees (or anything using readWorkspaceStatusLines) with a cwd that is not a git repository, a repo with a corrupted index, unreadable object files, or when git is unavailable. Permission errors on .git can also cause non-zero exit with sparse stderr.
Common situations: Passing a workspace/subdirectory path instead of the repo root; running inside a container where .git ownership triggers git's 'dubious ownership' refusal; detached/readonly mounts; git version mismatch producing empty stderr.
Related errors
- invalid_worktree_branch
- worktree_status_failed
- invalid auth slot path
- Autoresearch goal ${mission.slug} cannot complete until prof
- stderr || `git ${args.join(' ')} failed`
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/f5ea8044bdbf6578.
Report an issue: GitHub.