{"record":{"id":"b9524fc6697662db","repo":"affaan-m/ECC","slug":"worker-index-1-is-missing-a-task","errorCode":null,"errorMessage":"Worker ${index + 1} is missing a task","messagePattern":"Worker (.+?) is missing a task","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/tmux-worktree-orchestrator.js","lineNumber":196,"sourceCode":"  const workers = Array.isArray(config.workers) ? config.workers : [];\n  const globalSeedPaths = normalizeSeedPaths(config.seedPaths, repoRoot);\n  const sessionName = slugify(config.sessionName || repoName, 'session');\n  const worktreeRoot = path.resolve(config.worktreeRoot || path.dirname(repoRoot));\n  const coordinationRoot = path.resolve(\n    config.coordinationRoot || path.join(repoRoot, '.orchestration')\n  );\n  const coordinationDir = path.join(coordinationRoot, sessionName);\n  const baseRef = config.baseRef || 'HEAD';\n  const defaultLauncher = config.launcherCommand || '';\n\n  if (workers.length === 0) {\n    throw new Error('buildOrchestrationPlan requires at least one worker');\n  }\n\n  const seenSlugs = new Set();\n  const workerPlans = workers.map((worker, index) => {\n    if (!worker || typeof worker.task !== 'string' || worker.task.trim().length === 0) {\n      throw new Error(`Worker ${index + 1} is missing a task`);\n    }\n\n    const workerName = worker.name || `worker-${index + 1}`;\n    const workerSlug = slugify(workerName, `worker-${index + 1}`);\n\n    if (seenSlugs.has(workerSlug)) {\n      throw new Error(`Workers must have unique slugs — duplicate: ${workerSlug}`);\n    }\n    seenSlugs.add(workerSlug);\n\n    const branchName = `orchestrator-${sessionName}-${workerSlug}`;\n    const worktreePath = path.join(worktreeRoot, `${repoName}-${sessionName}-${workerSlug}`);\n    const workerCoordinationDir = path.join(coordinationDir, workerSlug);\n    const taskFilePath = path.join(workerCoordinationDir, 'task.md');\n    const handoffFilePath = path.join(workerCoordinationDir, 'handoff.md');\n    const statusFilePath = path.join(workerCoordinationDir, 'status.md');\n    const launcherCommand = worker.launcherCommand || defaultLauncher;\n    const workerSeedPaths = normalizeSeedPaths(worker.seedPaths, repoRoot);","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/tmux-worktree-orchestrator.js#L178-L214","documentation":"While mapping workers into plans, buildOrchestrationPlan validates that each worker has a non-empty task string and throws with the worker's 1-based index when it does not. This ensures every generated worktree session has real work assigned.","triggerScenarios":"Passing workers: [{}] or [{ task: '' }]; a worker object where task is null/undefined or a non-string (number, object); programmatically building workers where the task field is assigned the wrong key name.","commonSituations":"Config workers entries with 'description' instead of 'task'; deserialized JSON where tasks were dropped; iterating over input files and creating a worker placeholder before the task text is known.","solutions":["Set a non-empty task string on the worker named in the error message (index is 1-based).","Rename the wrong field (e.g. description -> task) in the worker config.","Validate the workers array at config load: every entry has typeof task === 'string' && task.trim().length > 0.","Fix the producer that generated the worker list to always emit task."],"exampleFix":"// before\nworkers: [{ name: 'worker-1', description: 'run tests' }]\n// after\nworkers: [{ name: 'worker-1', task: 'run tests' }]","handlingStrategy":"validation","validationCode":"config.workers.forEach((w, i) => {\n  if (!w || typeof w.task !== 'string' || w.task.trim().length === 0) {\n    throw new Error(`Worker ${i + 1} has no task`);\n  }\n});","typeGuard":"const hasTask = (w) => w != null && typeof w.task === 'string' && w.task.trim().length > 0;","tryCatchPattern":"try {\n  const plan = buildOrchestrationPlan(config);\n} catch (e) {\n  const m = String(e.message).match(/Worker (\\d+) is missing a task/);\n  if (m) console.error(`Fix worker #${m[1]} in config.workers`);\n  throw e;\n}","preventionTips":["Use the field name 'task' consistently in worker definitions.","Validate the workers array shape when the config is loaded.","Avoid deserializing worker lists without a schema check.","Require tasks in the config schema (min length 1 string)."],"tags":["orchestration","validation","tmux"],"backgroundTag":"empty-required-field","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}