🪢 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
chore: Improve errors events table (#12111)
Max Deichmann1f692e3328c9
diff --git a/packages/shared/src/errors/errorMessages.ts b/packages/shared/src/errors/errorMessages.tsnew file mode 100644index 0000000000..392eb58c59--- /dev/null+++ b/packages/shared/src/errors/errorMessages.ts@@ -0,0 +1,12 @@+/**+ * Shared error messages that can be used in both client and server contexts+ */++/**+ * Standard message for resource limit errors (memory, timeout, etc.)+ * Used when queries require too many resources to complete+ */+export const RESOURCE_LIMIT_ERROR_MESSAGE = [+ "Your query could not be completed because it required too many resources.",+ "Please narrow your request by adding more specific filters (e.g., a shorter date range).",+].join(" ");diff --git a/packages/shared/src/errors/index.ts b/packages/shared/src/errors/index.tsindex a001c6bec6..d3ba1d0157 100644--- a/packages/shared/src/errors/index.ts+++ b/packages/shared/src/errors/index.ts@@ -9,3 +9,4 @@ export { InternalServerError } from "./InternalServerError";export { LangfuseConflictError } from "./ConflictError";export { ServiceUnavailableError } from "./ServiceUnavailableError";export { NotImplementedError } from "./NotImplementedError";+export * from "./errorMessages";diff --git a/packages/shared/src/server/repositories/clickhouse.ts b/packages/shared/src/server/repositories/clickhouse.tsindex 176efdabcf..719ea74a74 100644--- a/packages/shared/src/server/repositories/clickhouse.ts+++ b/packages/shared/src/server/repositories/clickhouse.ts@@ -16,6 +16,7 @@ import {StorageServiceFactory,} from "../services/StorageService";import { ClickHouseSettings } from "@clickhouse/client";+import { RESOURCE_LIMIT_ERROR_MESSAGE } from "../../errors/errorMessages";/*** Custom error class for ClickHouse resource-related errors@@ -41,10 +42,7 @@ const ERROR_TYPE_CONFIG: Record<type ErrorType = keyof typeof ERROR_TYPE_CONFIG;export class ClickHouseResourceError extends Error {- static ERROR_ADVICE_MESSAGE = [- "Your query could not be completed because it required too many resources.",- "Please narrow your request by adding more specific filters (e.g., a shorter date range).",- ].join(" ");+ static ERROR_ADVICE_MESSAGE = RESOURCE_LIMIT_ERROR_MESSAGE;public readonly errorType: ErrorType;diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsxindex f4c93ff5aa..117e528979 100644--- a/web/src/components/table/data-table.tsx+++ b/web/src/components/table/data-table.tsx@@ -599,7 +599,7 @@ function TableBodyComponent<TData>({) : (<TableRow className="hover:bg-transparent"><TableCell colSpan={columns.length} className="h-24">- <div className="pointer-events-none absolute left-[50%] flex -translate-y-1/2 items-center justify-center">+ <div className="pointer-events-none absolute left-[50%] flex -translate-x-1/2 -translate-y-1/2 items-center justify-center text-center">{noResultsMessage ?? (<>No results.{" "}diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsxindex b5a099527b..3ba5de9a67 100644--- a/web/src/features/events/components/EventsTable.tsx+++ b/web/src/features/events/components/EventsTable.tsx@@ -23,6 +23,7 @@ import {TableViewPresetTableName,BatchActionType,ActionId,+ RESOURCE_LIMIT_ERROR_MESSAGE,} from "@langfuse/shared";import { cn } from "@/src/utils/tailwind";import { LevelColors } from "@/src/components/level-colors";@@ -405,6 +406,7 @@ export default function ObservationsEventsTable({handleAddToAnnotationQueue,dataUpdatedAt,ioLoading,+ isSilencedError,} = useEventsTableData({projectId,filterState,@@ -1248,17 +1250,30 @@ export default function ObservationsEventsTable({observations.status === "loading" || isViewLoading? { isLoading: true, isError: false }: observations.status === "error"- ? {- isLoading: false,- isError: true,- error: "",- }+ ? isSilencedError+ ? {+ isLoading: false,+ isError: false,+ data: [],+ }+ : {+ isLoading: false,+ isError: true,+ error: "",+ }: {isLoading: false,isError: false,data: rows,}}+ noResultsMessage={+ isSilencedError ? (+ <span className="text-muted-foreground">+ {RESOURCE_LIMIT_ERROR_MESSAGE}+ </span>+ ) : undefined+ }pagination={limitRows? undefineddiff --git a/web/src/features/events/hooks/useEventsTableData.ts b/web/src/features/events/hooks/useEventsTableData.tsindex c6f66ed95c..8775f0de5a 100644--- a/web/src/features/events/hooks/useEventsTableData.ts+++ b/web/src/features/events/hooks/useEventsTableData.ts@@ -66,8 +66,13 @@ export function useEventsTableData({],);+ const silentHttpCodes = [422];+const observations = api.events.all.useQuery(getAllPayload, {refetchOnWindowFocus: true,+ meta: {+ silentHttpCodes, // Turns off red bubble+ },});const batchIOPayload = useMemo(() => {@@ -105,16 +110,43 @@ export function useEventsTableData({staleTime: 0,});+ // Extract error information for display (only from observations.all, not batchIO)+ const error = observations.error;++ const errorHttpStatus = observations.error?.data?.httpStatus;++ const isSilencedError =+ observations.isError &&+ errorHttpStatus &&+ silentHttpCodes.includes(errorHttpStatus);+// Memoize joined data to prevent infinite re-renders- // Include ioDataQuery.isSuccess to ensure re-render when I/O loads- const joinedData = useMemo(- () =>- joinTableCoreAndMetrics<FullEventsObservation, EventBatchIOOutput>(- observations.data?.observations,- ioDataQuery.data,- ),- [observations.data?.observations, ioDataQuery.data],- );+ // Handle loading, error, and success states+ const joinedData = useMemo(() => {+ if (observations.isLoading) {+ return { status: "loading" as const, rows: undefined };+ }++ if (observations.isError) {+ if (isSilencedError) {+ // Treat silenced errors as successful with no data+ return { status: "success" as const, rows: [] };+ }+ return { status: "error" as const, rows: undefined };+ }++ // Success case - join the data+ return joinTableCoreAndMetrics<FullEventsObservation, EventBatchIOOutput>(+ observations.data?.observations,+ ioDataQuery.data,+ );+ }, [+ observations.isLoading,+ observations.isError,+ observations.data?.observations,+ ioDataQuery.data,+ isSilencedError,+ ]);// Fetch total countconst totalCountQuery = api.events.countAll.useQuery(getCountPayload, {@@ -174,5 +206,8 @@ export function useEventsTableData({addToQueueMutation,handleAddToAnnotationQueue,ioLoading: ioDataQuery.isLoading,+ error,+ errorHttpStatus,+ isSilencedError,};}diff --git a/web/src/features/events/server/eventsRouter.ts b/web/src/features/events/server/eventsRouter.tsindex 22636c940e..169f959777 100644--- a/web/src/features/events/server/eventsRouter.ts+++ b/web/src/features/events/server/eventsRouter.ts@@ -31,6 +31,7 @@ import {type AgentGraphDataResponse,} from "@/src/features/trace-graph-view/types";import type * as opentelemetry from "@opentelemetry/api";+import { TRPCError } from "@trpc/server";const GetAllEventsInput = EventsTableOptions.extend({...paginationZod,@@ -78,6 +79,11 @@ export const eventsRouter = createTRPCRouter({async (span) => {addAttributesToSpan({ span, input, orderBy: input.orderBy });+ throw new TRPCError({+ code: "UNPROCESSABLE_CONTENT",+ message: "Test error",+ });+return getEventList({projectId: ctx.session.projectId,filter: input.filter ?? [],