{"record":{"id":"3e9b5bca06d5cb15","repo":"ruvnet/ruflo","slug":"formulas-and-varsarray-must-have-the-same-length","errorCode":null,"errorMessage":"formulas and varsArray must have the same length","messagePattern":"formulas and varsArray must have the same length","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/plugins/gastown-bridge/src/wasm-loader.ts","lineNumber":894,"sourceCode":" * @param varsArray - Array of variable objects (one per formula)\n * @returns Array of cooked formulas\n *\n * @example\n * ```typescript\n * const cooked = await cookBatch(\n *   [formula1, formula2],\n *   [{ name: 'a' }, { name: 'b' }]\n * );\n * ```\n */\nexport async function cookBatch(\n  formulas: Formula[],\n  varsArray: Record<string, string>[]\n): Promise<Formula[]> {\n  const startTime = performance.now();\n\n  if (formulas.length !== varsArray.length) {\n    throw new Error('formulas and varsArray must have the same length');\n  }\n\n  const wasmModule = await loadFormulaWasm();\n\n  if (wasmModule) {\n    try {\n      const resultJson = wasmModule.cook_batch(\n        JSON.stringify(formulas),\n        JSON.stringify(varsArray)\n      );\n      const result = JSON.parse(resultJson) as Formula[];\n      recordTiming('cookBatch', startTime, true);\n      return result;\n    } catch (error) {\n      console.warn('[WASM Loader] cook_batch failed, using fallback:', error);\n    }\n  }\n","sourceCodeStart":876,"sourceCodeEnd":912,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/plugins/gastown-bridge/src/wasm-loader.ts#L876-L912","documentation":"cookBatch() received parallel arrays of formulas and per-formula variable objects whose lengths differ, so formulas cannot be paired with their variables. The length equality check runs before any WASM batch cooking; align the two arrays.","triggerScenarios":"Thrown at v3/plugins/gastown-bridge/src/wasm-loader.ts:894 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure both inputs have identical lengths before the operation; pad or truncate as appropriate for the domain.","Validate lengths at the call site and fail fast with both lengths in the message."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}