Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore(prompts): throw `400` if prompt name type mismatched (#6547)

marliessophie4c749298e66f
diff --git a/web/src/features/prompts/server/routers/promptRouter.ts b/web/src/features/prompts/server/routers/promptRouter.ts
index 35803c8ea6..61efbbd5bf 100644
--- a/web/src/features/prompts/server/routers/promptRouter.ts
+++ b/web/src/features/prompts/server/routers/promptRouter.ts
@@ -16,7 +16,11 @@ import { type Prompt, Prisma } from "@langfuse/shared/src/db";
import { createPrompt, duplicatePrompt } from "../actions/createPrompt";
import { checkHasProtectedLabels } from "../utils/checkHasProtectedLabels";
import { promptsTableCols } from "@/src/server/api/definitions/promptsTable";
-import { optionalPaginationZod, paginationZod } from "@langfuse/shared";
+import {
+ InvalidRequestError,
+ optionalPaginationZod,
+ paginationZod,
+} from "@langfuse/shared";
import { orderBy, singleFilter } from "@langfuse/shared";
import { LATEST_PROMPT_LABEL } from "@/src/features/prompts/constants";
import {
@@ -236,6 +240,12 @@ export const promptRouter = createTRPCRouter({
return prompt;
} catch (e) {
logger.error(e);
+ if (e instanceof InvalidRequestError) {
+ throw new TRPCError({
+ code: "BAD_REQUEST",
+ message: e.message,
+ });
+ }
throw e;
}
}),