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
- 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
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
- 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
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
- Invalid inputDim: ${this.config.inputDim}. Must be positive.
- Invalid outputDim: ${this.config.outputDim}. Must be positiv
- Invalid completion type
- Router multimodal is enabled but LLM_ROUTER_MULTIMODAL_MODEL
- Routes config must be a flat array of routes
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/43033bcb5922dea0.
Report an issue: GitHub.