{"record":{"id":"c7b3a208596ac450","repo":"mastra-ai/mastra","slug":"githubintegration-source-control-storage-has-not-b","errorCode":null,"errorMessage":"GithubIntegration source-control storage has not been initialized.","messagePattern":"GithubIntegration source-control storage has not been initialized\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/github/integration.ts","lineNumber":387,"sourceCode":"\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,\n  }: {\n    orgId: string;\n    externalSource: { type: string; externalId: string };\n  }): Promise<{ connection: IntegrationConnection; sourceId: string; issueId: string } | null> {\n    const target = parseGithubExternalTarget(externalSource.externalId);\n    if (!target) return null;","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/github/integration.ts#L369-L405","documentation":"The sourceControlStorage getter resolves storage from an explicit #sourceControlStorage or falls back to #storage.sourceControl; it throws when neither is available. Source-control storage backs installations and repositories, so the integration cannot operate on GitHub repos until it is injected.","triggerScenarios":"Accessing integration.sourceControlStorage — or anything downstream of it such as repository/credential resolution — before the storage context has been injected into the integration.","commonSituations":"Using the integration outside the factory that wires IntegrationContext; calling repository APIs during app startup prior to storage wiring; a host app that registers the integration but never provides sourceControl storage bindings.","solutions":["Initialize the integration with a storage context that includes a sourceControl namespace before use","Register the integration via the standard factory so storage injection happens automatically","Confirm the storage implementation passed in exposes a sourceControl sub-namespace"],"exampleFix":"// before\nconst gh = new GithubIntegration(config);\nawait gh.sourceControlStorage.repositories.get({ orgId, id }); // throws\n// after\nconst gh = new GithubIntegration(config);\nawait factory.initialize(gh, { storage }); // storage includes storage.sourceControl\nawait gh.sourceControlStorage.repositories.get({ orgId, id });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const repo = await gh.sourceControlStorage.repositories.get({ orgId, id });\n} catch (e) {\n  if (e.message === 'GithubIntegration source-control storage has not been initialized.') {\n    // ensure the integration was initialized with a storage context containing sourceControl\n  } else throw e;\n}","preventionTips":["Initialize integrations before any request handling that touches repositories","Verify the provided storage implementation exposes a sourceControl namespace","Gate startup readiness on storage-injection completion"],"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"}