{"record":{"id":"2f34edbfd8f255b9","repo":"mastra-ai/mastra","slug":"github-capabilities-require-a-github-connection","errorCode":null,"errorMessage":"GitHub capabilities require a GitHub connection.","messagePattern":"GitHub capabilities require a GitHub connection\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/platform/github/integration.ts","lineNumber":1544,"sourceCode":"    commitId: review.commitId,\n    submittedAt: review.submittedAt,\n  };\n}\n\nfunction parseReviewComment(comment: GithubReviewComment): ReviewComment {\n  return {\n    ...parseComment(comment),\n    path: comment.path,\n    line: comment.line,\n    side: comment.side?.toLowerCase() as 'left' | 'right' | null,\n    commitId: comment.commitId,\n    replyToId: comment.replyToId === null ? null : String(comment.replyToId),\n  };\n}\n\nfunction requireGithubConnection(connection: IntegrationConnection): void {\n  if (connection.type !== 'app-installation' && connection.type !== 'oauth') {\n    throw new Error('GitHub capabilities require a GitHub connection.');\n  }\n}\n\nfunction requireSingleSource(sourceIds: string[], message: string): string {\n  if (sourceIds.length !== 1) throw new Error(message);\n  return sourceIds[0]!;\n}\n\nfunction requireSource(sourceId: string | undefined, message: string): string {\n  if (!sourceId) throw new Error(message);\n  return sourceId;\n}\n\nfunction normalizeLabels(labels: string[] | undefined): string[] {\n  return [...new Set((labels ?? []).map(label => label.trim()).filter(Boolean))];\n}\n\nfunction parsePositiveCursor(cursor: string | undefined): number {","sourceCodeStart":1526,"sourceCodeEnd":1562,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/platform/github/integration.ts#L1526-L1562","documentation":"Thrown by requireGithubConnection when an IntegrationConnection is neither type 'app-installation' nor 'oauth'. GitHub capabilities can only execute against a GitHub-backed connection; any other connection type (or a connection from a different provider) is rejected up front.","triggerScenarios":"Calling a GitHub capability with a connection whose type is e.g. 'token', 'pat', 'gitlab', or another non-GitHub provider type stored on the org.","commonSituations":"Connecting a different VCS (GitLab/Bitbucket) integration but routing calls to the GitHub capability; misconfigured connection rows where type was saved incorrectly; switching providers without updating capability routing.","solutions":["Create or link a GitHub connection of type 'app-installation' (GitHub App) or 'oauth' for the org","Verify the connection row's type field in storage and correct it if it was persisted wrong","Route the request to the integration matching the connection's actual provider","Re-run the GitHub App installation or OAuth flow to establish a valid connection"],"exampleFix":"// before\nconst conn = { type: 'gitlab', ... }; github.capability(conn, ...);\n// after\nconst conn = await storage.connections.get({ orgId, type: 'app-installation', provider: 'github' });\ngithub.capability(conn, ...);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isGithubConnection(c: IntegrationConnection): c is IntegrationConnection & { type: 'app-installation' | 'oauth' } {\n  return c.type === 'app-installation' || c.type === 'oauth';\n}\nif (!isGithubConnection(connection)) throw new Error('route to non-GitHub integration instead');","tryCatchPattern":"try {\n  await github.capability(connection, ...);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('require a GitHub connection')) {\n    // route to the integration matching connection.type/provider\n  } else throw err;\n}","preventionTips":["Store provider alongside connection.type and dispatch capabilities by provider","Re-run the GitHub App install or OAuth flow for orgs missing a GitHub connection","Add a startup check that GitHub-enabled orgs have a github-typed connection","Never reuse a non-GitHub connection object for GitHub capabilities"],"tags":["github","connection","auth","validation"],"backgroundTag":"wrong-connection-type","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}