{"record":{"id":"6f0cfc59a985fa89","repo":"affaan-m/ECC","slug":"buildorchestrationplan-requires-at-least-one-worke","errorCode":null,"errorMessage":"buildOrchestrationPlan requires at least one worker","messagePattern":"buildOrchestrationPlan requires at least one worker","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/tmux-worktree-orchestrator.js","lineNumber":190,"sourceCode":"  };\n}\n\nfunction buildOrchestrationPlan(config = {}) {\n  const repoRoot = path.resolve(config.repoRoot || process.cwd());\n  const repoName = path.basename(repoRoot);\n  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}`);","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/tmux-worktree-orchestrator.js#L172-L208","documentation":"buildOrchestrationPlan assembles the per-worker tmux worktree plan and requires at least one worker in the config. It throws when the workers array is empty, since a plan with no workers would create nothing and mislead the caller into thinking orchestration succeeded.","triggerScenarios":"Calling buildOrchestrationPlan(config) (or the plan() wrapper) with config.workers === [], workers omitted but defaulted to [], or an upstream filter step that removed all workers.","commonSituations":"Empty 'workers' section in the orchestration config file; a CLI flag/filter (e.g. only run worker matching X) that matches nothing; generating config from a template where the workers array was never filled.","solutions":["Add at least one worker object with a non-empty task to config.workers.","Fix the upstream filter/selection so at least one worker survives.","Check the config file/loader to ensure the workers array is actually populated.","Guard the caller: validate workers.length > 0 and report a friendly config error before invoking the planner."],"exampleFix":"// before\nbuildOrchestrationPlan({ sessionName: 's1', workers: [] });\n// after\nbuildOrchestrationPlan({ sessionName: 's1', workers: [{ task: 'run tests' }] });","handlingStrategy":"validation","validationCode":"if (!Array.isArray(config.workers) || config.workers.length === 0) {\n  throw new Error('Orchestration config must define at least one worker');\n}","typeGuard":"const hasWorkers = (c) => Array.isArray(c?.workers) && c.workers.length > 0;","tryCatchPattern":"try {\n  const plan = buildOrchestrationPlan(config);\n} catch (e) {\n  if (String(e.message) === 'buildOrchestrationPlan requires at least one worker') {\n    console.error('No workers defined; check config.workers and any filters');\n  }\n  throw e;\n}","preventionTips":["Validate config.workers is a non-empty array at load time.","Audit any worker filters to ensure they cannot produce an empty set.","Provide example configs with at least one worker.","Add a unit test for the empty-workers config case."],"tags":["orchestration","validation","tmux"],"backgroundTag":"empty-result-set","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"}