{"record":{"id":"321d8f90546f78a5","repo":"ruvnet/ruflo","slug":"invalid-priority-priority","errorCode":null,"errorMessage":"Invalid priority: ${priority}","messagePattern":"Invalid priority: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/worker-queue.ts","lineNumber":329,"sourceCode":"      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      },\n      status: 'pending',\n      createdAt: new Date(),\n      retryCount: 0,\n      maxRetries: options?.maxRetries ?? this.config.maxRetries,\n    };\n","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/services/worker-queue.ts#L311-L347","documentation":"WorkerQueue.submitTask accepts options.priority only from the closed set ['critical', 'high', 'normal', 'low'] (default 'normal'). Any other string — 'medium', 'URGENT', 'highest' — fails the includes() check and throws with the offending value in the message. The validation happens on every submit, after the workerType check.","triggerScenarios":"Calling submitTask(type, payload, { priority: 'medium' }); priorities sourced from user input or another library whose scale differs (e.g. 1-5 numbers coerced oddly, or 'urgent'/'highest' vocabulary); case mismatches like 'High'.","commonSituations":"Porting code from a system with different priority vocabularies; passing priorities read from a config file or message queue header without whitelisting; typos and casing differences ('Critical' vs 'critical').","solutions":["Use one of: 'critical', 'high', 'normal', 'low' (lowercase, exact match) or omit priority to get 'normal'","If mapping from another scale, translate before submitting (e.g. 1->'low', 2->'normal', 3->'high', 4->'critical')","Whitelist external priority strings against the four allowed values and reject/fallback before calling submitTask","The error message includes the bad value — use it to spot casing or whitespace issues like ' high'"],"exampleFix":"// before\nawait queue.submitTask('audit', payload, { priority: 'urgent' }); // throws: Invalid priority: urgent\n\n// after\nconst PRIORITY = ['critical', 'high', 'normal', 'low'] as const;\nconst raw = String(userInput.priority ?? 'normal').toLowerCase() as (typeof PRIORITY)[number];\nconst priority = PRIORITY.includes(raw) ? raw : 'normal';\nawait queue.submitTask('audit', payload, { priority });","handlingStrategy":"type-guard","validationCode":"const priority = options?.priority ?? 'normal'; // rely on the default rather than passing 'medium'-style values from other vocabularies","typeGuard":"const WORKER_PRIORITIES = ['critical', 'high', 'normal', 'low'] as const;\nexport type WorkerPriority = (typeof WORKER_PRIORITIES)[number];\n\nfunction isWorkerPriority(value: unknown): value is WorkerPriority {\n  return typeof value === 'string' && (WORKER_PRIORITIES as readonly string[]).includes(value);\n}","tryCatchPattern":null,"preventionTips":["Type the priority option as the literal union so the compiler rejects 'medium'/'urgent' at build time","Normalize external priority input (lowercase + whitelist) before submitting tasks","Remember omitting priority is valid and defaults to 'normal'"],"tags":["worker-queue","priority","enum","validation","task-queue"],"backgroundTag":"invalid-enum-value","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}