{"record":{"id":"791d66a351515f1e","repo":"mastra-ai/mastra","slug":"source-control-missing-or-source-repository-missin","errorCode":"source_control_missing_or_source_repository_missing","errorMessage":"error.message (dynamic; FactorySourceSessionResolutionError)","messagePattern":"error\\.message \\(dynamic; FactorySourceSessionResolutionError\\)","errorType":"error_code","errorClass":"FactoryDispatchError","httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/routes/surface.ts","lineNumber":230,"sourceCode":"      destinationStage,\n      workItem: {\n        id: input.item.id,\n        role: input.role,\n        input: {\n          externalSource: input.item.externalSource,\n          parentWorkItemId: input.item.parentWorkItemId,\n          title: input.item.title,\n          stages: ['intake'],\n          sessions: input.item.sessions,\n          metadata: input.item.metadata,\n        },\n      },\n    });\n  } catch (error) {\n    if (error instanceof FactoryDispatchError) throw error;\n    if (error instanceof FactorySourceSessionResolutionError) {\n      const code = error.reason === 'connection' ? 'source_control_missing' : 'source_repository_missing';\n      throw new FactoryDispatchError(code, error.message, { cause: error });\n    }\n    if (error instanceof SourceControlConnectionNotFoundError) {\n      throw new FactoryDispatchError('source_control_missing', error.message, { cause: error });\n    }\n    if (error instanceof MaterializeError) {\n      throw new FactoryDispatchError(MATERIALIZE_FAILURE_CODE[error.code], error.message, { cause: error });\n    }\n    throw error;\n  }\n}\n\n/**\n * Build the {@link IntegrationContext} handed to an integration when the\n * factory collects its capabilities (routes, workers). One shape everywhere:\n * `assembleFactoryApiRoutes` uses it per registration, and `MastraFactory` uses it\n * when collecting integration workers at finalize.\n */\nexport function buildIntegrationContext(","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/routes/surface.ts#L212-L248","documentation":"When binding a factory rule, resolving the source-control session can fail with FactorySourceSessionResolutionError. If the resolution reason is not 'connection' (i.e. the repository itself is missing/unresolvable), the error is rethrown as FactoryDispatchError with code 'source_repository_missing', keeping the original message. It signals the source repository referenced by the work item can't be located.","triggerScenarios":"A rule binding whose item points to a repository slug/repo metadata that doesn't exist or isn't accessible in the resolved source-control session; FactorySourceSessionResolutionError thrown with reason other than 'connection'.","commonSituations":"Renamed/deleted repositories; metadata.repository strings that don't match the actual slug; wrong tenant/connection owning the repo; typo'd repo config in the board rule.","solutions":["Verify the repository referenced by item.metadata.repository exists and the slug is spelled correctly.","Check the source-control connection has access to that repository (permissions/org membership).","Inspect the original FactorySourceSessionResolutionError (attached as `cause`) for details.","Update the board rule or item metadata to reference the correct repository."],"exampleFix":"// before\nrepositorySlug: item.metadata?.repository // 'acme/old-repo' (renamed)\n// after\nrepositorySlug: item.metadata?.repository === 'acme/old-repo'\n  ? 'acme/new-repo'\n  : item.metadata?.repository","handlingStrategy":"try-catch","validationCode":"const repo = item.metadata?.repository;\nconst repoKnown = typeof repo === 'string' && repo.length > 0 && (await repoExistsInConnection(repo));\nif (!repoKnown) skipBinding(item);","typeGuard":"function hasRepositoryMetadata(item: { metadata?: { repository?: unknown } }): item is { metadata: { repository: string } } {\n  return typeof item.metadata?.repository === 'string' && item.metadata.repository !== '';\n}","tryCatchPattern":"try {\n  await prepareFactoryRuleBinding(input);\n} catch (e) {\n  if (e instanceof FactoryDispatchError && e.code === 'source_repository_missing') {\n    logger.warn('Repository not found for rule binding', { cause: e.cause, repo: input.item.metadata?.repository });\n  } else throw e;\n}","preventionTips":["Keep item.metadata.repository slugs in sync with actual repo names (watch renames/archives).","Verify the source-control connection grants access to the referenced repository.","Include the cause chain when logging so the original FactorySourceSessionResolutionError is visible."],"tags":["source-control","repository","dispatch","error-mapping"],"backgroundTag":"source-repository-missing","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}