{"record":{"id":"cff61757ec707a8b","repo":"ComposioHQ/composio","slug":"composio-client-is-not-initialized-please-initial","errorCode":null,"errorMessage":"Composio client is not initialized. Please initialize it first.","messagePattern":"Composio client is not initialized\\. Please initialize it first\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/composio.ts","lineNumber":411,"sourceCode":"    // instrument the provider since we are not using the provider class directly\n    telemetry.instrument(\n      this.provider,\n      this.provider.name ?? this.provider.constructor.name ?? 'unknown'\n    );\n\n    // Check for the latest version of the Composio SDK from NPM.\n    if (!this.config.disableVersionCheck) {\n      checkForLatestVersionFromNPM(version);\n    }\n  }\n\n  /**\n   * Get the Composio SDK client.\n   * @returns {ComposioClient} The Composio API client.\n   */\n  getClient(): ComposioClient {\n    if (!this.client) {\n      throw new Error('Composio client is not initialized. Please initialize it first.');\n    }\n    return this.client;\n  }\n\n  /**\n   * Get the configuration SDK is initialized with.\n   *\n   * Returns a frozen shallow clone — the SDK has already snapshotted\n   * configuration values such as `dangerouslyAllowAutoUploadDownloadFiles`,\n   * `fileUploadDirs`, and `fileDownloadDir` into its internal models, so\n   * mutating the live config object would silently no-op. Freezing makes\n   * that contract visible at the call site instead of letting the mutation\n   * appear successful.\n   *\n   * @returns {Readonly<ComposioConfig<TProvider>>} The frozen configuration\n   *   the SDK is initialized with.\n   */\n  getConfig(): Readonly<ComposioConfig<TProvider>> {","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/composio.ts#L393-L429","documentation":"Composio.getClient() returns the ComposioClient, but the client is only set after initialization succeeds (e.g. via an init/initialize flow or first authenticated request). Calling getClient() before that throws this error — it guards against a half-constructed Composio instance.","triggerScenarios":"Calling composio.getClient() immediately after constructing Composio without awaiting initialization; using the instance in code that runs before async init completes; accessing getClient() after a failed init left client null.","commonSituations":"Top-level code executing before await init; race conditions in app startup; init failed silently earlier and later code assumes success.","solutions":["Await the initialization flow before calling getClient()","Check initialization state (e.g. a isInitialized flag or that init didn't throw) before access","Re-run init with a valid API key if it previously failed","Store the client returned by init rather than re-fetching it eagerly"],"exampleFix":"// before\nconst composio = new Composio({ apiKey });\nconst client = composio.getClient(); // may throw\n// after\nconst composio = new Composio({ apiKey });\nawait composio.init(); // complete initialization first\nconst client = composio.getClient();","handlingStrategy":"validation","validationCode":"if (!composio.isInitialized) await composio.init(); // or await whatever init flow you use\nconst client = composio.getClient();","typeGuard":"const ready = (c: Composio): boolean => (c as any).client != null;","tryCatchPattern":"try { composio.getClient(); } catch (e) { if (e.message.includes('not initialized')) await initThenRetry(); }","preventionTips":["Await initialization before any getClient() call","Fail fast if init throws instead of continuing"],"tags":["lifecycle","initialization","typescript","sdk"],"backgroundTag":"client-not-initialized","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}