{"record":{"id":"f5ea8044bdbf6578","repo":"Yeachan-Heo/oh-my-codex","slug":"workspace-status-failed","errorCode":"workspace_status_failed","errorMessage":"workspace_status_failed:${cwd}","messagePattern":"workspace_status_failed:(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/worktree.ts","lineNumber":144,"sourceCode":"    encoding: 'utf-8',\n      windowsHide: true,\n    });\n  if (result.status !== 0) {\n    const stderr = (result.stderr || '').trim();\n    throw new Error(stderr || `worktree_status_failed:${worktreePath}`);\n  }\n  return (result.stdout || '').trim() !== '';\n}\n\nexport function readWorkspaceStatusLines(cwd: string): string[] {\n  const result = spawnSync('git', ['status', '--porcelain', '--untracked-files=all'], {\n    cwd,\n    encoding: 'utf-8',\n      windowsHide: true,\n    });\n  if (result.status !== 0) {\n    const stderr = (result.stderr || '').trim();\n    throw new Error(stderr || `workspace_status_failed:${cwd}`);\n  }\n  return (result.stdout || '')\n    .split(/\\r?\\n/)\n    .map((line) => line.trimEnd())\n    .filter(Boolean);\n}\n\nexport function assertCleanLeaderWorkspaceForWorkerWorktrees(cwd: string): void {\n  const lines = readWorkspaceStatusLines(cwd);\n  if (lines.length === 0) return;\n  const preview = lines.slice(0, 8).join(' | ');\n  throw new Error(\n    `leader_workspace_dirty_for_worktrees:${resolve(cwd)}:${preview}:commit_or_stash_before_omx_team`,\n  );\n}\n\nfunction listWorktrees(repoRoot: string): GitWorktreeEntry[] {\n  const raw = readGit(repoRoot, ['worktree', 'list', '--porcelain']);","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/worktree.ts#L126-L162","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before: dubious ownership in container causes status to fail\n# after:\ngit config --global --add safe.directory /workspace\n# or in code: spawnSync('git',['config','--global','--add','safe.directory',repoRoot])","handlingStrategy":"validation","validationCode":"function isUsableGitRepo(cwd: string): boolean {\n  const r = spawnSync('git', ['rev-parse','--is-inside-work-tree'], { cwd, encoding: 'utf-8' });\n  if (r.status !== 0) return false;\n  const safe = spawnSync('git', ['config','--get','safe.directory'], { encoding: 'utf-8' });\n  return true;\n}","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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"],"tags":["git","git-status","workspace","validation"],"backgroundTag":"git-status-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}