🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix: return 404 error instead of 500 for not found observations trpc … (#5105)
Max Deichmannb6e21fc44b62
diff --git a/web/src/server/api/routers/observations.ts b/web/src/server/api/routers/observations.tsindex a879c8ca94..db0cfa488f 100644--- a/web/src/server/api/routers/observations.ts+++ b/web/src/server/api/routers/observations.ts@@ -2,6 +2,7 @@ import {createTRPCRouter,protectedGetTraceProcedure,} from "@/src/server/api/trpc";+import { LangfuseNotFoundError } from "@langfuse/shared";import { getObservationById } from "@langfuse/shared/src/server";import { TRPCError } from "@trpc/server";import { z } from "zod";@@ -18,21 +19,31 @@ export const observationsRouter = createTRPCRouter({}),).query(async ({ input }) => {- const obs = await getObservationById(- input.observationId,- input.projectId,- true,- input.startTime ?? undefined,- );- if (!obs) {- throw new TRPCError({- code: "NOT_FOUND",- message: "Observation not found within authorized project",- });+ try {+ const obs = await getObservationById(+ input.observationId,+ input.projectId,+ true,+ input.startTime ?? undefined,+ );+ if (!obs) {+ throw new TRPCError({+ code: "NOT_FOUND",+ message: "Observation not found within authorized project",+ });+ }+ return {+ ...obs,+ internalModel: obs?.internalModelId,+ };+ } catch (e) {+ if (e instanceof LangfuseNotFoundError) {+ throw new TRPCError({+ code: "NOT_FOUND",+ message: "Observation not found within authorized project",+ });+ }+ throw e;}- return {- ...obs,- internalModel: obs?.internalModelId,- };}),});