{"record":{"id":"b78516b6a4a9c8d6","repo":"Yeachan-Heo/oh-my-codex","slug":"team-worktree-worker-name-required","errorCode":"team_worktree_worker_name_required","errorMessage":"team_worktree_worker_name_required","messagePattern":"team_worktree_worker_name_required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/worktree.ts","lineNumber":217,"sourceCode":"  const stderr = (result.stderr || '').trim();\n  throw new Error(stderr || `worktree_prune_failed:${worktreePath}`);\n}\n\nfunction resolveBranchName(input: WorktreePlanInput): string | null {\n  if (!input.mode.enabled || input.mode.detached) return null;\n\n  if (input.scope === 'launch') {\n    return input.mode.name;\n  }\n\n  if (input.scope === 'autoresearch') {\n    const runTag = sanitizePathToken(input.worktreeTag || 'run');\n    return `autoresearch/${sanitizePathToken(input.mode.name)}/${runTag}`;\n  }\n\n  const workerName = (input.workerName || '').trim();\n  if (!workerName) {\n    throw new Error('team_worktree_worker_name_required');\n  }\n\n  return `${input.mode.name}/${workerName}`;\n}\n\nfunction resolveWorktreePath(input: WorktreePlanInput, repoRoot: string): string {\n  const parent = dirname(repoRoot);\n  const bucket = `${basename(repoRoot)}.omx-worktrees`;\n\n  if (input.scope === 'launch') {\n    if (!input.mode.enabled || input.mode.detached) {\n      return join(parent, bucket, 'launch-detached');\n    }\n    return join(parent, bucket, `launch-${sanitizePathToken(input.mode.name)}`);\n  }\n\n  if (input.scope === 'autoresearch') {\n    if (!input.mode.enabled || input.mode.detached) {","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/worktree.ts#L199-L235","documentation":"Thrown when planning a worker-scoped worktree branch and the worker name is empty after trimming. Worker branches are named `<mode>/<workerName>`, so an empty worker name would produce an invalid/duplicated branch. The library requires an explicit non-empty workerName in worker scope.","triggerScenarios":"Calling planWorktreeTarget with scope 'worker' (mode enabled, not detached) and workerName undefined, null, or whitespace-only.","commonSituations":"Passing an options object built from CLI args where --worker was omitted; workerName sourced from an env var that's unset; trimming logic upstream that reduces the name to ''; misconfigured team definition missing the worker name field.","solutions":["Supply a non-empty workerName whenever scope is 'worker' (e.g. 'researcher', 'coder')","Default workerName from your own config before calling the planner if the field is optional in your system","Validate workerName early in your CLI/config layer and fail with a helpful message","If no per-worker identity is needed, use launch scope instead, which derives a name from mode and run tag"],"exampleFix":"// before\nplanWorktreeTarget({ scope: 'worker', mode: { enabled: true, name: 'bench' }, workerName: workerName }); // undefined\n\n// after\nif (scope === 'worker' && !(workerName ?? '').trim()) {\n  throw new Error('Missing --worker name for worker-scoped worktree');\n}\nplanWorktreeTarget({ scope: 'worker', mode: { enabled: true, name: 'bench' }, workerName: workerName!.trim() });","handlingStrategy":"validation","validationCode":"function hasWorkerName(input: { workerName?: string | null }): boolean {\n  return !!(input.workerName ?? '').trim();\n}","typeGuard":"function isNonEmptyWorkerName(s: unknown): s is string {\n  return typeof s === 'string' && s.trim().length > 0;\n}","tryCatchPattern":"catch (e) { if (e instanceof Error && e.message === 'team_worktree_worker_name_required') { /* prompt for worker name or default it */ } else throw e; }","preventionTips":["Make workerName a required CLI/config field when scope is 'worker'","Validate trimmed non-emptiness at config parse time","Provide sensible defaults (mode name, hostname) instead of passing undefined"],"tags":["worktree","validation","required-field","team"],"backgroundTag":"missing-required-parameter","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}