{"record":{"id":"9b978b0757d67584","repo":"mastra-ai/mastra","slug":"github-repository-is-invalid","errorCode":null,"errorMessage":"GitHub repository is invalid.","messagePattern":"GitHub repository is invalid\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/github/session-subscriptions.ts","lineNumber":124,"sourceCode":"  }\n\n  const projectRepository = await github.sourceControlStorage.projectRepositories.get({\n    orgId,\n    id: projectRepositoryId,\n  });\n  if (!projectRepository) throw new Error('Project repository not found for this organization.');\n  const connection = await github.sourceControlStorage.connections.get({ orgId, id: projectRepository.connectionId });\n  if (!connection) throw new Error('Source-control connection not found for this organization.');\n  const repository = await github.sourceControlStorage.repositories.get({ orgId, id: projectRepository.repositoryId });\n  if (!repository) throw new Error('Repository not found for this organization.');\n  const installation = await github.sourceControlStorage.installations.get({ orgId, id: connection.installationId });\n  if (!installation) throw new Error('Source-control installation not found for this organization.');\n  return { context, projectRepository, connection, installation, repository, orgId, userId };\n}\n\nasync function verifyPullRequest(target: SessionTarget, pullRequest: number, github: GithubIntegration) {\n  const [owner, repo] = target.repository.slug.split('/');\n  if (!owner || !repo) throw new Error('GitHub repository is invalid.');\n  const octokit = github.getInstallationOctokit(Number(target.installation.externalId));\n  const { data } = await octokit.pulls.get({ owner, repo, pull_number: pullRequest });\n  if (String(data.base.repo.id) !== target.repository.externalId)\n    throw new Error('Pull request repository does not match the active project repository.');\n}\n\nasync function subscriptionInput(target: SessionTarget, pullRequestNumber: number) {\n  return {\n    orgId: target.orgId,\n    installationExternalId: target.installation.externalId,\n    projectRepositoryId: target.projectRepository.id,\n    repositoryExternalId: target.repository.externalId,\n    repositorySlug: target.repository.slug,\n    changeRequestId: String(pullRequestNumber),\n    sessionId: target.context.session.id,\n    ownerId: target.context.session.ownerId,\n    resourceId: target.connection.factoryProjectId,\n    threadId: target.context.threadId!,","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/github/session-subscriptions.ts#L106-L142","documentation":"verifyPullRequest splits the target repository's slug into owner and repo names before calling the GitHub API. If the slug does not split into both parts (empty owner or repo), this error is thrown. It guards against malformed repository slugs stored in the database.","triggerScenarios":"target.repository.slug lacks the 'owner/name' format, e.g. empty string, 'owner/' or '/name', so destructuring yields an undefined segment.","commonSituations":"Corrupt or manually edited repository rows; import scripts writing slugs without an owner portion.","solutions":["Fix the repository slug in storage to the canonical 'owner/repo' format","Re-sync the repository from GitHub so the slug is recomputed correctly","Validate slug format at repository ingestion time before persisting"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const [owner, repo] = slug.split('/');\nif (!owner || !repo) throw new Error(`invalid repository slug: ${slug}`);","typeGuard":"function isWellFormedSlug(slug: string): boolean {\n  const [owner, repo] = slug.split('/');\n  return Boolean(owner && repo);\n}","tryCatchPattern":null,"preventionTips":["Validate slug format ('owner/repo') at repository ingestion time","Re-sync repository records if slugs look malformed","Restrict manual edits to repository rows"],"tags":["validation","github","slug"],"backgroundTag":"invalid-repository-slug","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}