mastra-ai/mastra · error
GithubIntegration storage has not been initialized.
Error message
GithubIntegration storage has not been initialized.
What it means
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.
Source
Thrown at mastracode/factory/src/integrations/github/integration.ts:381
}
/** App slug — the URL name used to build the install URL. */
get slug(): string {
return this.#slug;
}
/** Whether a GitHub login belongs to this integration's App. */
isFactoryCommentAuthor(login: string | null | undefined): boolean {
return typeof login === 'string' && login.toLowerCase() === `${this.#slug}[bot]`.toLowerCase();
}
/** Extra bot logins authorized to trigger author-gated PR notifications. */
get authorizedBots(): readonly string[] {
return this.#authorizedBots;
}
get genericStorage(): IntegrationContext['storage']['generic'] {
if (!this.#storage) throw new Error('GithubIntegration storage has not been initialized.');
return this.#storage.generic;
}
get sourceControlStorage(): IntegrationContext['storage']['sourceControl'] {
const storage = this.#sourceControlStorage ?? this.#storage?.sourceControl;
if (!storage) throw new Error('GithubIntegration source-control storage has not been initialized.');
return storage;
}
get integrationStorage(): GithubSubscriptionStorage {
if (!this.#storage) throw new Error('GithubIntegration storage has not been initialized.');
return this.#storage.generic as unknown as GithubSubscriptionStorage;
}
/** Resolve a stored GitHub locator without scanning installations or repositories. */
async #resolveIntakeDispatch({
orgId,
externalSource,View on GitHub (pinned to 75dd419e61)
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
Example fix
// before
const gh = new GithubIntegration(config);
gh.genericStorage.get('key'); // throws
// after
const gh = new GithubIntegration(config);
factory.initialize(gh, { storage }); // injects #storage
gh.genericStorage.get('key'); Defensive patterns
Strategy: try-catch
Try / catch
try {
const storage = gh.genericStorage;
} catch (e) {
if (e.message === 'GithubIntegration storage has not been initialized.') {
// await factory initialization before using the integration
} else throw e;
} Prevention
- 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
When it happens
Trigger: Reading integration.genericStorage after constructing GithubIntegration but before the factory/framework calls the storage initialization hook that sets #storage.
Common situations: 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.
Related errors
- GithubIntegration source-control storage has not been initia
- Factory storage domain '${this.name}' has not been registere
- Browser not launched
- SlackProvider not attached to Mastra. Call __attach() first.
- IssueReconcileWorker: call init() before start()
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/9926d9b886eaea31.
Report an issue: GitHub.