Skip to content

Commit 7d05d15

Browse files
test: simplify numeric issue ID regression coverage
Reuse the shared event fixtures, replace the numeric autofix handler list with one route, and shorten the API guidance. Co-Authored-By: David Cramer <david@sentry.io>
1 parent 5964215 commit 7d05d15

3 files changed

Lines changed: 23 additions & 51 deletions

File tree

‎docs/contributing/api-patterns.md‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ await api.issues.update({
6565

6666
### Resolved Issue IDs
6767

68-
After resolving an issue, use `String(issue.id)` for follow-up API requests,
69-
including events, external links, and Seer analysis. Do not switch back to
70-
`issue.shortId`: short-ID resolution can fail for legacy mixed-case project
71-
slugs even when numeric-ID lookup succeeds. Keep short IDs for display.
68+
Use `String(issue.id)` for API requests after resolving an issue. Short IDs can
69+
fail to resolve for legacy mixed-case project slugs; keep them for display.
7270

7371
### Multi-Region Support
7472

‎packages/mcp-core/src/tools/catalog/get-issue-details.numeric-id.test.ts‎

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ const context = {
1919
userId: "1",
2020
};
2121

22-
// Short IDs for legacy mixed-case project slugs can fail to resolve even though
23-
// the numeric ID works. Reject every short-ID follow-up, including optional data.
2422
describe("issue details with an unresolvable short ID", () => {
2523
it.each([
2624
{
@@ -65,39 +63,26 @@ describe("issue details with an unresolvable short ID", () => {
6563
),
6664
},
6765
])("loads $name and enrichment by numeric ID", async ({ call }) => {
68-
const requestedIssueIds: string[] = [];
6966
const base = `https://sentry.io/api/0/organizations/${organizationSlug}`;
7067
mswServer.use(
7168
http.get(`${base}/issues/`, () => HttpResponse.json([issueFixture])),
72-
http.get(`${base}/issues/:issueId/*`, ({ params, request }) => {
73-
const requestedId = String(params.issueId);
74-
requestedIssueIds.push(requestedId);
75-
if (requestedId !== issueId) {
76-
return HttpResponse.json(
77-
{ detail: "The requested resource does not exist" },
78-
{ status: 404 },
79-
);
80-
}
81-
const path = new URL(request.url).pathname;
82-
if (path.includes("/events/")) {
83-
return HttpResponse.json(eventsFixture);
84-
}
85-
if (path.endsWith("/external-issues/")) {
86-
return HttpResponse.json([
87-
{
88-
id: "123",
89-
issueId,
90-
serviceType: "github",
91-
displayName: "example/app#123",
92-
webUrl: "https://github.com/example/app/issues/123",
93-
},
94-
]);
95-
}
96-
if (path.endsWith("/autofix/")) {
97-
return HttpResponse.json(autofixStateFixture);
98-
}
99-
return HttpResponse.json(issueFixture);
100-
}),
69+
http.get(`${base}/issues/${issueFixture.shortId}/*`, () =>
70+
HttpResponse.json({ detail: "Not found" }, { status: 404 }),
71+
),
72+
http.get(`${base}/issues/${issueId}/autofix/`, () =>
73+
HttpResponse.json(autofixStateFixture),
74+
),
75+
http.get(`${base}/issues/${issueId}/external-issues/`, () =>
76+
HttpResponse.json([
77+
{
78+
id: "123",
79+
issueId,
80+
serviceType: "github",
81+
displayName: "example/app#123",
82+
webUrl: "https://github.com/example/app/issues/123",
83+
},
84+
]),
85+
),
10186
);
10287

10388
const result = await call();
@@ -106,7 +91,5 @@ describe("issue details with an unresolvable short ID", () => {
10691
expect(result).toContain(eventsFixture.id);
10792
expect(result).toContain("## Seer Analysis");
10893
expect(result).toContain("**example/app#123** (github)");
109-
expect(requestedIssueIds.length).toBeGreaterThanOrEqual(3);
110-
expect(new Set(requestedIssueIds)).toEqual(new Set([issueId]));
11194
});
11295
});

‎packages/mcp-server-mocks/src/index.ts‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,20 +1334,11 @@ export const restHandlers = buildHandlers([
13341334
path: "/api/0/organizations/sentry-mcp-evals/issues/CLOUDFLARE-MCP-41/autofix/",
13351335
fetch: () => HttpResponse.json({ autofix: null }),
13361336
},
1337-
// Issue details use the resolved numeric ID for enrichment requests.
1338-
...[
1339-
issueFixture.id,
1340-
"7890123456", // PERF-N1-001
1341-
"123456", // DEFAULT-001 / CONTEXT-001
1342-
"123456789", // TEAM-ISSUE-001
1343-
"6898891101", // MCP-SERVER-EQE
1344-
"7777777777", // FUTURE-TYPE-001
1345-
"4256774711", // BLOG-CSP-4XC
1346-
].map((issueId) => ({
1347-
method: "get" as const,
1348-
path: `/api/0/organizations/sentry-mcp-evals/issues/${issueId}/autofix/`,
1337+
{
1338+
method: "get",
1339+
path: "/api/0/organizations/sentry-mcp-evals/issues/:issueId(\\d+)/autofix/",
13491340
fetch: () => HttpResponse.json({ autofix: null }),
1350-
})),
1341+
},
13511342
{
13521343
method: "post",
13531344
path: "/api/0/organizations/sentry-mcp-evals/issues/CLOUDFLARE-MCP-42/autofix/",

0 commit comments

Comments
 (0)