fix(app): handle nullable detail consumers
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { FunctionReturnType } from 'convex/server';
|
||||
import { NextResponse } from 'next/server';
|
||||
import { proxyWorker } from '@/lib/agent-worker-proxy';
|
||||
import { convexAuthNextjsToken } from '@convex-dev/auth/nextjs/server';
|
||||
@@ -35,7 +36,14 @@ export const POST = async (
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
const details = await fetchQuery(api.threads.get, { threadId }, { token });
|
||||
const details = (await fetchQuery(
|
||||
api.threads.get,
|
||||
{ threadId },
|
||||
{ token },
|
||||
)) as FunctionReturnType<typeof api.threads.get> | null;
|
||||
if (details === null) {
|
||||
return NextResponse.json({ error: 'Thread not found.' }, { status: 404 });
|
||||
}
|
||||
const latestJob = details.latestJob;
|
||||
const canSendToWorker =
|
||||
latestJob &&
|
||||
|
||||
Reference in New Issue
Block a user