{"record":{"id":"24bf90305f128eef","repo":"ruvnet/ruflo","slug":"sdkbridge-not-initialized-call-initialize-first","errorCode":null,"errorMessage":"SDKBridge not initialized. Call initialize() first.","messagePattern":"SDKBridge not initialized\\. Call initialize\\(\\) first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/integration/src/sdk-bridge.ts","lineNumber":422,"sourceCode":"  private generateMigrationExample(oldAPI: string, newAPI: string): string {\n    // Generate a simple migration example\n    const oldParts = oldAPI.split('.');\n    const newParts = newAPI.split('.');\n\n    const oldCall = oldParts.length > 1\n      ? `${oldParts[0]}.${oldParts[1]}(args)`\n      : `${oldAPI}(args)`;\n\n    const newCall = newParts.length > 1\n      ? `new ${newParts[0]}().${newParts[1]}(args)`\n      : `${newAPI}(args)`;\n\n    return `// Before:\\n${oldCall}\\n\\n// After:\\n${newCall}`;\n  }\n\n  private ensureInitialized(): void {\n    if (!this.initialized) {\n      throw new Error('SDKBridge not initialized. Call initialize() first.');\n    }\n  }\n}\n\n/**\n * Create and initialize an SDK bridge\n */\nexport async function createSDKBridge(\n  config?: Partial<SDKBridgeConfig>\n): Promise<SDKBridge> {\n  const bridge = new SDKBridge(config);\n  await bridge.initialize();\n  return bridge;\n}\n","sourceCodeStart":404,"sourceCodeEnd":437,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/integration/src/sdk-bridge.ts#L404-L437","documentation":"Every SDKBridge method that depends on runtime detection funnels through ensureInitialized(); if initialize() never ran or failed, the bridge throws this guard error. this.initialized only becomes true after version detection, compatibility checks, and feature detection all succeed.","triggerScenarios":"Calling any bridged API on a new SDKBridge() instance before await bridge.initialize() completes, or after initialize() failed (e.g. on an SDK version incompatibility), leaving initialized === false.","commonSituations":"Forgetting to await the async initialize(); an earlier init failure being swallowed so the bridge is used uninitialized; lazily-created bridge instances racing the init promise in a callback.","solutions":["await bridge.initialize() once before any API call, or use the createSDKBridge() factory which constructs and initializes in one step","If initialize() already ran and failed, fix that root error first (e.g. the version incompatibility) — this guard is only a symptom","Cache the initialized promise and await it in every entry point that touches the bridge"],"exampleFix":"// before\nconst bridge = new SDKBridge(config);\nbridge.someApi(args); // throws: init not awaited\n\n// after\nconst bridge = await createSDKBridge(config); // constructs AND initializes\nbridge.someApi(args);","handlingStrategy":"validation","validationCode":"// Single shared init gate — every call site awaits the same promise\nlet bridgePromise: Promise<SDKBridge> | null = null;\nfunction getBridge(): Promise<SDKBridge> {\n  bridgePromise ??= createSDKBridge(config);\n  return bridgePromise;\n}\n// usage: const bridge = await getBridge();","typeGuard":null,"tryCatchPattern":"try {\n  bridge.someApi(args);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('SDKBridge not initialized')) {\n    await bridge.initialize(); // or createSDKBridge() — then retry once\n    return bridge.someApi(args);\n  }\n  throw e;\n}","preventionTips":["Always construct via the createSDKBridge factory","Export one initialized singleton instead of passing raw instances around","Treat initialization failure as fatal at startup — log and exit rather than limping on"],"tags":["initialization","lifecycle","sdk","async"],"backgroundTag":"not-initialized","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}