{"record":{"id":"72a49e6ddb0f981e","repo":"ruvnet/ruflo","slug":"invalid-worker-type","errorCode":null,"errorMessage":"Invalid worker type","messagePattern":"Invalid worker type","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/worker-queue.ts","lineNumber":323,"sourceCode":"   * Enqueue a new task\n   */\n  async enqueue(\n    workerType: HeadlessWorkerType,\n    payload: QueueTask['payload'] = {},\n    options?: {\n      priority?: WorkerPriority;\n      maxRetries?: number;\n      timeoutMs?: number;\n    }\n  ): Promise<string> {\n    // Initialize if needed\n    if (!this.initialized) {\n      await this.initialize();\n    }\n\n    // Validate worker type\n    if (!workerType || typeof workerType !== 'string') {\n      throw new Error('Invalid worker type');\n    }\n\n    // Validate priority\n    const priority = options?.priority || 'normal';\n    if (!['critical', 'high', 'normal', 'low'].includes(priority)) {\n      throw new Error(`Invalid priority: ${priority}`);\n    }\n\n    const taskId = `task-${Date.now()}-${randomUUID().slice(0, 8)}`;\n\n    const task: QueueTask = {\n      id: taskId,\n      workerType,\n      priority,\n      payload: {\n        ...payload,\n        timeoutMs: options?.timeoutMs || this.config.defaultTimeoutMs,\n      },","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/services/worker-queue.ts#L305-L341","documentation":"WorkerQueue.submitTask validates its first argument before queuing: workerType must be a non-empty string. Anything else — undefined, null, a number, an empty string — throws 'Invalid worker type'. This is input validation at the queue boundary, fired before the task id is even generated.","triggerScenarios":"Calling queue.submitTask(undefined, payload) because a variable was never assigned; passing a numeric worker id (submitTask(3, ...)); passing '' from an empty config field; a refactor that changed the workerType parameter order so a payload object lands in the workerType slot.","commonSituations":"Dynamic dispatch code where the worker type comes from user input, CLI args, or JSON config and can be missing; default parameters that silently produce undefined; parameter-order mistakes after signature changes to submitTask.","solutions":["Pass a concrete non-empty worker type string, e.g. queue.submitTask('audit', { ... })","Trace where the workerType value originates — it is undefined/empty at the call site, so the producer (config, CLI parse, caller) dropped it","Check the submitTask signature: workerType is the first positional parameter, payload second, options third","Add a local assert before enqueueing when the type comes from external input"],"exampleFix":"// before\nconst type = config.job?.worker; // undefined when config omits it\nawait queue.submitTask(type, payload); // throws: Invalid worker type\n\n// after\nconst type = config.job?.worker;\nif (!type || typeof type !== 'string') throw new Error(`worker type missing in config`);\nawait queue.submitTask(type, payload);","handlingStrategy":"type-guard","validationCode":"if (typeof workerType !== 'string' || workerType.length === 0) {\n  throw new Error(`workerType must be a non-empty string, got ${JSON.stringify(workerType)}`);\n}\nawait queue.submitTask(workerType, payload, options);","typeGuard":"function isNonEmptyString(value: unknown): value is string {\n  return typeof value === 'string' && value.trim().length > 0;\n}","tryCatchPattern":"try {\n  await queue.submitTask(type, payload);\n} catch (e) {\n  if (/^Invalid worker type$/.test(String(e?.message))) {\n    // the producer of `type` is broken — log it with full context, do not retry blindly\n    console.error('submitTask rejected workerType:', JSON.stringify(type));\n  }\n  throw e;\n}","preventionTips":["Type workerType parameters as string at the boundary and validate external input before it reaches the queue","Lint against submitTask(anyValue, ...) — untyped dispatch hides undefined producers","Fail fast at config-load time when a required worker type field is missing"],"tags":["worker-queue","validation","input-validation","task-queue"],"backgroundTag":"argument-validation-failed","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}