fix(chat): handle inactive botid gracefully (#1437)

This commit is contained in:
dancer 2026-03-02 15:06:22 +00:00 committed by GitHub
parent ad47aa0ee0
commit 314f8ced57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 30 additions and 9 deletions

View file

@ -1,4 +1,3 @@
import { checkBotId } from "botid/server";
import { geolocation, ipAddress } from "@vercel/functions";
import {
convertToModelMessages,
@ -8,6 +7,7 @@ import {
stepCountIs,
streamText,
} from "ai";
import { checkBotId } from "botid/server";
import { after } from "next/server";
import { createResumableStreamContext } from "resumable-stream";
import { auth, type UserType } from "@/app/(auth)/auth";
@ -64,9 +64,12 @@ export async function POST(request: Request) {
const { id, message, messages, selectedChatModel, selectedVisibilityType } =
requestBody;
const [botResult, session] = await Promise.all([checkBotId(), auth()]);
const [botResult, session] = await Promise.all([
checkBotId().catch(() => null),
auth(),
]);
if (botResult.isBot) {
if (botResult?.isBot) {
return new ChatbotError("unauthorized:chat").toResponse();
}