{"record":{"id":"e03d7385b17fc995","repo":"ruvnet/ruflo","slug":"unknown-consensus-algorithm-this-config-algorit","errorCode":null,"errorMessage":"Unknown consensus algorithm: ${this.config.algorithm}","messagePattern":"Unknown consensus algorithm: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/swarm/src/consensus/index.ts","lineNumber":117,"sourceCode":"          threshold: this.config.threshold,\n          timeoutMs: this.config.timeoutMs,\n          maxRounds: this.config.maxRounds,\n          requireQuorum: this.config.requireQuorum,\n        });\n        break;\n\n      case 'paxos':\n        // Fall back to Raft for Paxos (similar guarantees)\n        this.implementation = createRaftConsensus(this.nodeId, {\n          threshold: this.config.threshold,\n          timeoutMs: this.config.timeoutMs,\n          maxRounds: this.config.maxRounds,\n          requireQuorum: this.config.requireQuorum,\n        });\n        break;\n\n      default:\n        throw new Error(`Unknown consensus algorithm: ${this.config.algorithm}`);\n    }\n\n    await this.implementation.initialize();\n\n    // Forward events\n    this.implementation.on('consensus.achieved', (data) => {\n      this.emit('consensus.achieved', data);\n    });\n\n    this.implementation.on('leader.elected', (data) => {\n      this.emit('leader.elected', data);\n    });\n\n    this.emit('initialized', {\n      nodeId: this.nodeId,\n      algorithm: this.config.algorithm\n    });\n  }","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/swarm/src/consensus/index.ts#L99-L135","documentation":"ConsensusEngine.initialize() switches on config.algorithm and constructs the matching implementation: 'raft', 'byzantine', 'gossip', or 'paxos' (which aliases Raft with similar guarantees). Any other value reaches the default branch and throws during initialization, before an implementation is ever created. The default when algorithm is omitted is 'raft'.","triggerScenarios":"A typo in config.algorithm such as 'bft' or 'raftv2'; a value loaded from an env var with wrong casing ('Raft'); a version upgrade that renamed or removed an algorithm name; config JSON passing an arbitrary string without validation.","commonSituations":"Algorithm chosen from user input or config files without an allowlist; docs/example drift between package versions; copy-pasted configs from other libraries (e.g. 'pbft' instead of 'byzantine').","solutions":["Set algorithm to one of the supported values: 'raft' | 'byzantine' | 'gossip' | 'paxos' (or omit it — default is 'raft').","Validate the value against that allowlist at config load time, before constructing the engine.","If you need BFT semantics, use 'byzantine'; 'paxos' silently maps to Raft — pick 'raft' explicitly for clarity.","Check the package version's ConsensusAlgorithm type — the union is the source of truth."],"exampleFix":"// before\nconst engine = new ConsensusEngine('n1', { algorithm: 'bft' }); // typo\nawait engine.initialize(); // throws: Unknown consensus algorithm\n\n// after\nconst engine = new ConsensusEngine('n1', { algorithm: 'byzantine' }); // raft | byzantine | gossip | paxos\nawait engine.initialize();","handlingStrategy":"validation","validationCode":"const ALGORITHMS = ['raft', 'byzantine', 'gossip', 'paxos'];\nif (!ALGORITHMS.includes(config.algorithm)) {\n  throw new Error(`algorithm must be one of ${ALGORITHMS.join(', ')}, got '${config.algorithm}'`);\n}\nconst engine = new ConsensusEngine(nodeId, config);\nawait engine.initialize();","typeGuard":"const ALGORITHMS = ['raft', 'byzantine', 'gossip', 'paxos'] as const;\nexport type KnownAlgorithm = (typeof ALGORITHMS)[number];\nfunction isKnownAlgorithm(a: string): a is KnownAlgorithm {\n  return (ALGORITHMS as readonly string[]).includes(a);\n}","tryCatchPattern":"try {\n  await engine.initialize(config);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unknown consensus algorithm:')) {\n    // fall back to the default 'raft' or fail config load with a clear message\n  } else {\n    throw e;\n  }\n}","preventionTips":["Validate algorithm against the ConsensusAlgorithm union at config load time (zod/manual allowlist).","Remember 'paxos' silently maps to Raft — prefer explicit 'raft'.","Re-check the supported union after package upgrades."],"tags":["consensus","configuration","factory","enum-validation"],"backgroundTag":"invalid-config-value","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}