ruvnet/ruflo · error

Worker config must include id

Error message

Worker config must include id

What it means

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 -> []).

Source

Thrown at v3/@claude-flow/integration/src/worker-base.ts:274

  protected metrics: WorkerMetrics;

  /** Message queue for coordination */
  protected messageQueue: Message[] = [];

  /** Memory reference (for persistent memory integration) */
  protected memoryBankId?: string;

  /**
   * Create a new WorkerBase instance
   *
   * @param config - Worker configuration
   */
  constructor(config: WorkerConfig) {
    super();

    // Validate required fields
    if (!config.id) {
      throw new Error('Worker config must include id');
    }

    this.id = config.id;
    this.type = config.type || 'generic';
    this.name = config.name || `${this.type}-${this.id}`;
    this.capabilities = config.capabilities || [];
    this.config = config;
    this.createdAt = Date.now();

    // Set specialization embedding
    if (config.specialization) {
      this.specialization = config.specialization instanceof Float32Array
        ? config.specialization
        : new Float32Array(config.specialization);
    }

    // Initialize metrics
    this.metrics = {

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Pass a unique non-empty id in the WorkerConfig
  2. Generate one when unknown: id: crypto.randomUUID()
  3. Check for key typos (workerId, worker_id) when building the config, and assert the shape before constructing

Example fix

// before
const worker = new CoderWorker({ type: 'coder' }); // id missing -> throws

// after
const worker = new CoderWorker({ id: `coder-${crypto.randomUUID()}`, type: 'coder' });
Defensive patterns

Strategy: type-guard

Validate before calling

// Validate before constructing — id is the only non-defaultable field
function assertValidWorkerConfig(c: unknown): void {
  const id = (c as { id?: unknown })?.id;
  if (typeof id !== 'string' || id === '') {
    throw new Error('WorkerConfig.id must be a non-empty string');
  }
}

Type guard

function isWorkerConfig(c: unknown): c is WorkerConfig {
  return typeof c === 'object' && c !== null &&
    typeof (c as Record<string, unknown>).id === 'string' &&
    ((c as Record<string, unknown>).id as string).length > 0;
}

Try / catch

try {
  const w = new MyWorker(cfg);
} catch (e) {
  if (e instanceof Error && e.message === 'Worker config must include id') {
    // fix the config source (mapping/typo) — do not silently default ids
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/43033bcb5922dea0. Report an issue: GitHub.