diff --git a/packages/mcp-core/src/tools/support/issue-linking/app.test.ts b/packages/mcp-core/src/tools/support/issue-linking/app.test.ts index 6276e6d62..98760200c 100644 --- a/packages/mcp-core/src/tools/support/issue-linking/app.test.ts +++ b/packages/mcp-core/src/tools/support/issue-linking/app.test.ts @@ -287,6 +287,13 @@ describe("linkAppIssue", () => { expect(searches).toBe(1); }); + it("says the App must be installed when the organization has no installation", async () => { + mockDiscovery({ slug: "other" }); + await expect(linkAppIssue(api, params)).rejects.toThrow( + "The 'linear' Sentry App is not installed in organization 'example'", + ); + }); + it("requires a valid installed callback even for an existing association", async () => { mockDiscovery({ links: [association], diff --git a/packages/mcp-core/src/tools/support/issue-linking/app.ts b/packages/mcp-core/src/tools/support/issue-linking/app.ts index ce193039c..e17c566f6 100644 --- a/packages/mcp-core/src/tools/support/issue-linking/app.ts +++ b/packages/mcp-core/src/tools/support/issue-linking/app.ts @@ -317,7 +317,11 @@ export async function linkAppIssue( (installation) => installation.app.slug === appSlug && installation.status === "installed", ); - if (installed.length !== 1) + if (installed.length === 0) + throw new UserInputError( + `The '${appSlug}' Sentry App is not installed in organization '${params.organizationSlug}', so Sentry cannot link this issue to it. Someone who can manage integrations must install it under Settings > Integrations in Sentry, then retry.`, + ); + if (installed.length > 1) throw new UserInputError(`Expected one installed Sentry App '${appSlug}'.`); const installation = installed[0]!; const matchingComponents = components.filter(