Skip to content

Commit 3815df7

Browse files
committed
update error to 400 from 404 for invalid agentRunId
1 parent df82d54 commit 3815df7

File tree

1 file changed

+6
-5
lines changed
  • web/src/app/api/v1/chat/completions

1 file changed

+6
-5
lines changed

web/src/app/api/v1/chat/completions/route.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,21 @@ export async function POST(req: NextRequest) {
5353
)
5454
}
5555

56-
const runIdFromBody = body.codebuff_metadata?.agentRunId
57-
if (!runIdFromBody) {
56+
const runIdFromBody: string = body.codebuff_metadata?.agentRunId
57+
if (!runIdFromBody || typeof runIdFromBody !== 'string') {
5858
return NextResponse.json(
59-
{ message: 'No agent run ID found in request body' },
59+
{ message: 'No agentRunId found in request body' },
6060
{ status: 400 }
6161
)
6262
}
63+
6364
const runId = runIdFromBody
6465
? getAgentRunFromId({ agentRunId: runIdFromBody, userId, fields: ['id'] })
6566
: null
6667
if (!runId) {
6768
return NextResponse.json(
68-
{ message: `Agent Run ID Not Found: ${runIdFromBody}` },
69-
{ status: 404 }
69+
{ message: `agentRunId Not Found: ${runIdFromBody}` },
70+
{ status: 400 }
7071
)
7172
}
7273

0 commit comments

Comments
 (0)