mastra-ai/mastra · error
Platform GitHub event polling requires the mounted Mastra Co
Error message
Platform GitHub event polling requires the mounted Mastra Code controller.
What it means
Thrown by PlatformGithubIntegration.workers() when event polling, PR reconcile, or issue reconcile is enabled but the IntegrationContext has no mounted Mastra Code controller. The PlatformGithubEventWorker needs the controller to dispatch events into the code platform, so without it the workers cannot function and the library refuses to return a broken worker set.
Source
Thrown at mastracode/factory/src/integrations/platform/github/integration.ts:753
return Promise.all(
usableInstallations.map(installation =>
this.versionControl.registerInstallation({
orgId,
userId,
installation: {
externalId: String(installation.installationId),
accountName: installation.accountLogin,
accountType: installation.accountType,
},
}),
),
);
}
workers(ctx: IntegrationContext): MastraWorker[] {
if (!this.#pollingEnabled && !this.#pullRequestReconcileEnabled && !this.#issueReconcileEnabled) return [];
if (!ctx.controller) {
throw new Error('Platform GitHub event polling requires the mounted Mastra Code controller.');
}
return [
new PlatformGithubEventWorker({
client: this.#client,
controller: ctx.controller,
github: this,
storage: ctx.storage.generic as unknown as PlatformGithubEventStorage,
ingestFactoryEvent: attachGithubRules(this, ctx),
reconcileFactoryState: this.#pullRequestReconcileEnabled
? attachGithubReconciler(this, ctx, input => this.fetchPullRequestState(input))
: undefined,
reconcileIssuesFactoryState: this.#issueReconcileEnabled
? attachGithubIssueReconciler(this, ctx, input => this.fetchIssueState(input))
: undefined,
pollEventsEnabled: this.#pollingEnabled,
intervalMs: this.#pollingIntervalMs,
pullRequestReconcileIntervalMs: this.#pullRequestReconcileIntervalMs,
issueReconcileIntervalMs: this.#issueReconcileIntervalMs,View on GitHub (pinned to 75dd419e61)
Solutions
- Mount the Mastra Code controller in the host and pass it in the IntegrationContext so ctx.controller is set
- If polling is not needed, disable all three flags (polling, pullRequestReconcile, issueReconcile) so workers() returns [] early
- Check bootstrap order: ensure the controller is created before integration.workers(ctx) is called
- Log/assert ctx.controller in host startup to catch mis-wiring early
Example fix
// before
mastraServer.mount({ integrations: [githubIntegration] }); // no controller
// after
mastraServer.mount({ controller: mastraCodeController, integrations: [githubIntegration] }); Defensive patterns
Strategy: validation
Validate before calling
const ctx: IntegrationContext = { controller: mastraCodeController };
if ((github.isPollingEnabled?.() ?? true) && !ctx.controller) {
throw new Error('Mount the Mastra Code controller before enabling GitHub event polling');
} Type guard
function hasController(ctx: IntegrationContext): ctx is IntegrationContext & { controller: NonNullable<IntegrationContext['controller']> } {
return ctx.controller != null;
} Try / catch
try {
const workers = githubIntegration.workers(ctx);
} catch (err) {
if (err instanceof Error && err.message.includes('mounted Mastra Code controller')) {
console.error('Controller not mounted: disable polling flags or wire controller into IntegrationContext');
} else throw err;
} Prevention
- Always construct IntegrationContext with the controller before mounting integrations
- Disable polling/reconcile flags in environments that intentionally lack a controller
- Assert controller presence in host startup tests
- Keep controller creation ordered before integration registration
When it happens
Trigger: Constructing PlatformGithubIntegration with polling, pullRequestReconcile, or issueReconcile enabled, then mounting it in a host that calls integration.workers(ctx) with ctx.controller undefined or null.
Common situations: Embedding the GitHub integration in a custom Mastra server that does not mount the Mastra Code controller; bootstrapping order issue where workers() is invoked before controller registration; copying integration setup into a new entrypoint without the controller wiring.
Related errors
- GitHub capabilities require an app-installation connection.
- GitHub reconcile worker requires a pull request or issue rec
- GitHub pull request reconcile interval must be a positive nu
- GitHub issue reconcile interval must be a positive number.
- Platform GitHub event polling interval must be a positive nu
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/6074b91cec72aa4b.
Report an issue: GitHub.