{"record":{"id":"9926d9b886eaea31","repo":"mastra-ai/mastra","slug":"githubintegration-storage-has-not-been-initialized","errorCode":null,"errorMessage":"GithubIntegration storage has not been initialized.","messagePattern":"GithubIntegration storage has not been initialized\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/github/integration.ts","lineNumber":381,"sourceCode":"  }\n\n  /** App slug — the URL name used to build the install URL. */\n  get slug(): string {\n    return this.#slug;\n  }\n\n  /** Whether a GitHub login belongs to this integration's App. */\n  isFactoryCommentAuthor(login: string | null | undefined): boolean {\n    return typeof login === 'string' && login.toLowerCase() === `${this.#slug}[bot]`.toLowerCase();\n  }\n\n  /** Extra bot logins authorized to trigger author-gated PR notifications. */\n  get authorizedBots(): readonly string[] {\n    return this.#authorizedBots;\n  }\n\n  get genericStorage(): IntegrationContext['storage']['generic'] {\n    if (!this.#storage) throw new Error('GithubIntegration storage has not been initialized.');\n    return this.#storage.generic;\n  }\n\n  get sourceControlStorage(): IntegrationContext['storage']['sourceControl'] {\n    const storage = this.#sourceControlStorage ?? this.#storage?.sourceControl;\n    if (!storage) throw new Error('GithubIntegration source-control storage has not been initialized.');\n    return storage;\n  }\n\n  get integrationStorage(): GithubSubscriptionStorage {\n    if (!this.#storage) throw new Error('GithubIntegration storage has not been initialized.');\n    return this.#storage.generic as unknown as GithubSubscriptionStorage;\n  }\n\n  /** Resolve a stored GitHub locator without scanning installations or repositories. */\n  async #resolveIntakeDispatch({\n    orgId,\n    externalSource,","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/github/integration.ts#L363-L399","documentation":"This getter lazily exposes the integration's generic storage but throws if the integration's storage context (#storage) was never assigned. The integration is designed to be constructed with config first and have storage injected later; accessing genericStorage before injection is a lifecycle error.","triggerScenarios":"Reading integration.genericStorage after constructing GithubIntegration but before the factory/framework calls the storage initialization hook that sets #storage.","commonSituations":"Instantiating the integration manually and using it directly instead of through the factory that wires storage; subscribing to webhooks or reading subscription data during bootstrap before storage injection runs; unit-testing the integration without providing an IntegrationContext.","solutions":["Ensure the integration is registered through the factory/framework path that injects storage after construction","If constructing manually, call the storage initialization entry point with an IntegrationContext before touching storage getters","In tests, provide a storage stub via the same initialization hook"],"exampleFix":"// before\nconst gh = new GithubIntegration(config);\ngh.genericStorage.get('key'); // throws\n// after\nconst gh = new GithubIntegration(config);\nfactory.initialize(gh, { storage }); // injects #storage\ngh.genericStorage.get('key');","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const storage = gh.genericStorage;\n} catch (e) {\n  if (e.message === 'GithubIntegration storage has not been initialized.') {\n    // await factory initialization before using the integration\n  } else throw e;\n}","preventionTips":["Always obtain integrations from the factory after initialization rather than constructing them ad hoc","Do not touch integration storage getters during bootstrap before storage wiring completes","In tests, provide an IntegrationContext with storage stubs before asserting on storage behavior"],"tags":["lifecycle","storage","initialization"],"backgroundTag":"dependency-not-initialized","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}