{"record":{"id":"43033bcb5922dea0","repo":"ruvnet/ruflo","slug":"worker-config-must-include-id","errorCode":null,"errorMessage":"Worker config must include id","messagePattern":"Worker config must include id","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/integration/src/worker-base.ts","lineNumber":274,"sourceCode":"  protected metrics: WorkerMetrics;\n\n  /** Message queue for coordination */\n  protected messageQueue: Message[] = [];\n\n  /** Memory reference (for persistent memory integration) */\n  protected memoryBankId?: string;\n\n  /**\n   * Create a new WorkerBase instance\n   *\n   * @param config - Worker configuration\n   */\n  constructor(config: WorkerConfig) {\n    super();\n\n    // Validate required fields\n    if (!config.id) {\n      throw new Error('Worker config must include id');\n    }\n\n    this.id = config.id;\n    this.type = config.type || 'generic';\n    this.name = config.name || `${this.type}-${this.id}`;\n    this.capabilities = config.capabilities || [];\n    this.config = config;\n    this.createdAt = Date.now();\n\n    // Set specialization embedding\n    if (config.specialization) {\n      this.specialization = config.specialization instanceof Float32Array\n        ? config.specialization\n        : new Float32Array(config.specialization);\n    }\n\n    // Initialize metrics\n    this.metrics = {","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/integration/src/worker-base.ts#L256-L292","documentation":"WorkerBase's constructor validates the one field it cannot default — config.id — and throws immediately when it is missing or empty (falsy). Every other field has a fallback (type -> 'generic', name -> `${type}-${id}`, capabilities -> []).","triggerScenarios":"Constructing any worker subclass with a config that has no id, id: undefined, or id: '' — typically a dynamically built config object where the id key was never set or was typo'd.","commonSituations":"Config assembled from partial external data (env/db rows) where the id column is absent; field renamed in types (workerId vs id) so the runtime object misses it; spreading defaults that overwrite id with undefined.","solutions":["Pass a unique non-empty id in the WorkerConfig","Generate one when unknown: id: crypto.randomUUID()","Check for key typos (workerId, worker_id) when building the config, and assert the shape before constructing"],"exampleFix":"// before\nconst worker = new CoderWorker({ type: 'coder' }); // id missing -> throws\n\n// after\nconst worker = new CoderWorker({ id: `coder-${crypto.randomUUID()}`, type: 'coder' });","handlingStrategy":"type-guard","validationCode":"// Validate before constructing — id is the only non-defaultable field\nfunction assertValidWorkerConfig(c: unknown): void {\n  const id = (c as { id?: unknown })?.id;\n  if (typeof id !== 'string' || id === '') {\n    throw new Error('WorkerConfig.id must be a non-empty string');\n  }\n}","typeGuard":"function isWorkerConfig(c: unknown): c is WorkerConfig {\n  return typeof c === 'object' && c !== null &&\n    typeof (c as Record<string, unknown>).id === 'string' &&\n    ((c as Record<string, unknown>).id as string).length > 0;\n}","tryCatchPattern":"try {\n  const w = new MyWorker(cfg);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Worker config must include id') {\n    // fix the config source (mapping/typo) — do not silently default ids\n  }\n  throw e;\n}","preventionTips":["Make WorkerConfig.id required in your own types so the compiler catches omissions","Generate ids (crypto.randomUUID()) at the edge when configs come from external data","Validate config objects built from env/db rows before constructing workers"],"tags":["validation","configuration","constructor","worker"],"backgroundTag":"missing-required-field","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}