{"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":null,"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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/tmux-worktree-orchestrator.js#L178-L214","documentation":"Thrown inside the workers.map loop in buildOrchestrationPlan() when a worker entry is null/undefined or its task field is missing, not a string, or only whitespace. The task string is what gets written to task_file inside the worktree and ultimately drives the worker agent, so an empty task would produce an empty instruction file. The 1-based index in the message identifies which worker in the array failed.","triggerScenarios":"config.workers = [{ name: 'alpha' }] (task omitted); config.workers = [{ task: '   ' }]; config.workers = [{ task: 42 }] (number, not string); config.workers = [null, { task: '...' }] (first entry is null); a worker built from a partial JSON payload where the task field was renamed.","commonSituations":"A YAML workers list where one entry has only a name and the task lives under a different key (e.g. 'prompt'); CLI argument parsing drops the task when it contains shell metacharacters; an LLM-generated config forgets the field; programmatic builders that conditionally include the task and skip it on a code path.","solutions":["Give every worker a non-empty task string: { name: 'alpha', task: 'refactor the auth module' }.","Filter or reject malformed workers before calling buildOrchestrationPlan: workers = workers.filter(w => w?.task?.trim()).","Validate upstream with a schema (zod / ajv) so the error surfaces at config load, not deep in the orchestrator.","Use the index in the message to find the offending entry — it is 1-based."],"exampleFix":"// before\nworkers: [\n  { name: 'alpha', launcherCommand: 'claude' },   // no task\n  { name: 'beta', task: 'fix tests' },\n]\n// -> Worker 1 is missing a task\n\n// after\nworkers: [\n  { name: 'alpha', task: 'refactor auth module', launcherCommand: 'claude' },\n  { name: 'beta', task: 'fix tests' },\n]","handlingStrategy":"validation","validationCode":"function cleanWorkers(workers) {\n  return (workers || []).filter(w =>\n    w && typeof w.task === 'string' && w.task.trim().length > 0\n  );\n}\n\nconfig.workers = cleanWorkers(config.workers);\nif (config.workers.length === 0) throw new Error('All workers missing task');","typeGuard":"function isWorkerWithTask(value) {\n  return !!value &&\n    typeof value === 'object' &&\n    typeof value.task === 'string' &&\n    value.task.trim().length > 0;\n}","tryCatchPattern":"try {\n  buildOrchestrationPlan(config);\n} catch (error) {\n  if (/is missing a task/.test(error.message)) {\n    config.workers = config.workers.filter(isWorkerWithTask);\n    buildOrchestrationPlan(config);\n    return;\n  }\n  throw error;\n}","preventionTips":["Validate each worker object with a schema (zod / ajv) at config load.","Use the 1-based index in the message to locate the offending entry quickly.","Treat missing task as a config error, not a defaultable field.","In tests, build workers from a factory that always sets task."],"tags":["orchestration","configuration","validation","worker"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}