{"record":{"id":"6074b91cec72aa4b","repo":"mastra-ai/mastra","slug":"platform-github-event-polling-requires-the-mounted","errorCode":null,"errorMessage":"Platform GitHub event polling requires the mounted Mastra Code controller.","messagePattern":"Platform GitHub event polling requires the mounted Mastra Code controller\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/platform/github/integration.ts","lineNumber":753,"sourceCode":"    return Promise.all(\n      usableInstallations.map(installation =>\n        this.versionControl.registerInstallation({\n          orgId,\n          userId,\n          installation: {\n            externalId: String(installation.installationId),\n            accountName: installation.accountLogin,\n            accountType: installation.accountType,\n          },\n        }),\n      ),\n    );\n  }\n\n  workers(ctx: IntegrationContext): MastraWorker[] {\n    if (!this.#pollingEnabled && !this.#pullRequestReconcileEnabled && !this.#issueReconcileEnabled) return [];\n    if (!ctx.controller) {\n      throw new Error('Platform GitHub event polling requires the mounted Mastra Code controller.');\n    }\n    return [\n      new PlatformGithubEventWorker({\n        client: this.#client,\n        controller: ctx.controller,\n        github: this,\n        storage: ctx.storage.generic as unknown as PlatformGithubEventStorage,\n        ingestFactoryEvent: attachGithubRules(this, ctx),\n        reconcileFactoryState: this.#pullRequestReconcileEnabled\n          ? attachGithubReconciler(this, ctx, input => this.fetchPullRequestState(input))\n          : undefined,\n        reconcileIssuesFactoryState: this.#issueReconcileEnabled\n          ? attachGithubIssueReconciler(this, ctx, input => this.fetchIssueState(input))\n          : undefined,\n        pollEventsEnabled: this.#pollingEnabled,\n        intervalMs: this.#pollingIntervalMs,\n        pullRequestReconcileIntervalMs: this.#pullRequestReconcileIntervalMs,\n        issueReconcileIntervalMs: this.#issueReconcileIntervalMs,","sourceCodeStart":735,"sourceCodeEnd":771,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/platform/github/integration.ts#L735-L771","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nmastraServer.mount({ integrations: [githubIntegration] }); // no controller\n// after\nmastraServer.mount({ controller: mastraCodeController, integrations: [githubIntegration] });","handlingStrategy":"validation","validationCode":"const ctx: IntegrationContext = { controller: mastraCodeController };\nif ((github.isPollingEnabled?.() ?? true) && !ctx.controller) {\n  throw new Error('Mount the Mastra Code controller before enabling GitHub event polling');\n}","typeGuard":"function hasController(ctx: IntegrationContext): ctx is IntegrationContext & { controller: NonNullable<IntegrationContext['controller']> } {\n  return ctx.controller != null;\n}","tryCatchPattern":"try {\n  const workers = githubIntegration.workers(ctx);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('mounted Mastra Code controller')) {\n    console.error('Controller not mounted: disable polling flags or wire controller into IntegrationContext');\n  } else throw err;\n}","preventionTips":["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"],"tags":["configuration","github","workers","bootstrap"],"backgroundTag":"missing-dependency-injection","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}