🪢 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(web): stop residual expected-error noise from batch deletes and evaluator form (#15806)
Nikita Kabardin6d57a46b9dae
diff --git a/web/src/__tests__/server/traces-batch-delete-trpc.servertest.ts b/web/src/__tests__/server/traces-batch-delete-trpc.servertest.tsindex 4aa1f11197..bb80ef38c5 100644--- a/web/src/__tests__/server/traces-batch-delete-trpc.servertest.ts+++ b/web/src/__tests__/server/traces-batch-delete-trpc.servertest.ts@@ -334,24 +334,58 @@ describe("traces.deleteMany batch action", () => {).resolves.toBeNull();});- it("rejects deletes with an empty traceIds array even for batch actions", async () => {- // An empty selection while select-all is armed signals a client-side- // consistency issue; the server contract requires at least one traceId- // for every delete and must fail loudly rather than absorb it.+ it("dispatches a batch action even when traceIds drained to empty", async () => {+ // Paging or a background refetch can drain the visible-page selection+ // while select-all is armed; the batch path deletes by query and ignores+ // traceIds, so the dispatch must proceed instead of failing on a phantom+ // id precondition.const { projectId, caller } = await createCaller();const batchActionId = `${projectId}-traces-trace-delete`;+ const query = traceDeleteQuery(`delete-user-${randomUUID()}`);++ await caller.traces.deleteMany({+ projectId,+ traceIds: [],+ isBatchAction: true,+ query,+ });++ const batchAction = await prisma.batchAction.findUniqueOrThrow({+ where: { id: batchActionId },+ });+ expect(batchAction.status).toBe(BatchActionStatus.Queued);+ expect(batchAction.query).toMatchObject(query);+ });++ it("still rejects id-based deletes with an empty traceIds array", async () => {+ const { projectId, caller } = await createCaller();await expect(caller.traces.deleteMany({projectId,traceIds: [],- isBatchAction: true,- query: traceDeleteQuery(`delete-user-${randomUUID()}`),+ isBatchAction: false,}),).rejects.toMatchObject({code: "BAD_REQUEST",message: expect.stringContaining("Minimum 1 traceId is required."),});+ });++ it("rejects batch actions without a query", async () => {+ const { projectId, caller } = await createCaller();+ const batchActionId = `${projectId}-traces-trace-delete`;++ await expect(+ caller.traces.deleteMany({+ projectId,+ traceIds: [],+ isBatchAction: true,+ }),+ ).rejects.toMatchObject({+ code: "BAD_REQUEST",+ message: expect.stringContaining("Batch actions require a query."),+ });await expect(prisma.batchAction.findUnique({ where: { id: batchActionId } }),diff --git a/web/src/features/evals/components/inner-evaluator-form.tsx b/web/src/features/evals/components/inner-evaluator-form.tsxindex b985449c08..7865e24ca3 100644--- a/web/src/features/evals/components/inner-evaluator-form.tsx+++ b/web/src/features/evals/components/inner-evaluator-form.tsx@@ -37,7 +37,8 @@ import {observationVariableMapping,} from "@langfuse/shared";import { useRouter } from "next/router";-import { trpcErrorToast } from "@/src/utils/trpcErrorToast";+import { TRPCClientError } from "@trpc/client";+import { reportError } from "@/src/utils/reportError";import { Slider } from "@/src/components/ui/slider";import { Card } from "@/src/components/ui/card";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";@@ -532,15 +533,13 @@ export const InnerEvaluatorForm = (props: {]);const utils = api.useUtils();+ // No onError override: the react-query default (handleTrpcError) owns+ // classification, Sentry capture, and the standard error toast.const createJobMutation = api.evals.createJob.useMutation({onSuccess: () => utils.models.invalidate(),- // Defining onError replaces the react-query default that shows the- // standard error toast, so trigger it explicitly.- onError: trpcErrorToast,});const updateJobMutation = api.evals.updateEvalJob.useMutation({onSuccess: () => utils.evals.invalidate(),- onError: trpcErrorToast,});const [availableVariables, setAvailableVariables] = useState<typeof availableTraceEvalVariables | typeof availableDatasetEvalVariables@@ -720,10 +719,17 @@ export const InnerEvaluatorForm = (props: {}}).catch((error) => {- // Mutation failures are surfaced via the onError toast; this catch- // also swallows post-success errors (onFormSuccess, router.push),- // so keep a console trace for those.- console.error("Evaluator form submission failed", error);+ // Mutation failures were already classified + toasted by the+ // react-query default onError; only post-success errors+ // (onFormSuccess, router.push) need reporting here. reportError+ // captures with an area tag and warns — console.error would mint a+ // second, unclassified Sentry event via captureConsoleIntegration.+ if (!(error instanceof TRPCClientError)) {+ reportError(error, {+ area: "evals",+ extra: { context: "evaluator-form-post-submit" },+ });+ }});}diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsxindex cc0cce8231..4e289800f2 100644--- a/web/src/features/events/components/EventsTable.tsx+++ b/web/src/features/events/components/EventsTable.tsx@@ -951,11 +951,10 @@ export default function ObservationsEventsTable({}, [observations.rows, selectedRows]);const handleDeleteTraces = async ({ projectId }: { projectId: string }) => {- // Select-all deletes are dispatched even if a background refetch drained- // the visible-page selection to [] while the dialog was open: the server- // requires at least one traceId regardless, so such a dispatch fails- // loudly (as in the v3 traces table) — an empty selection while- // select-all is armed signals a consistency issue, not a no-op.+ // Select-all deletes are dispatched even if paging or a background+ // refetch drained the visible-page selection to []: the batch path+ // deletes by query server-side and ignores traceIds. Only an id-based+ // delete with nothing resolvable is a no-op.if (!selectAll && selectedTraceIds.length === 0) return;await traceDeleteMutation.mutateAsync({@@ -1018,10 +1017,9 @@ export default function ObservationsEventsTable({type: BatchActionType.Delete,label: "Delete Traces",description: `${itemCountDisplay} ${selectedItemCount === 1 ? "item is" : "items are"} selected, spanning ${traceCountDisplay} unique ${selectedUniqueTraceCount === 1 ? "trace" : "traces"}. A trace is always deleted as a whole — if at least one of its observations is selected, all of its observations are deleted with it. This action cannot be undone. Trace deletion happens asynchronously and may take up to 24 hours.`,- // Select-all is not gated on the visible-page selection; if that- // selection drained to empty, dispatch fails loudly with the- // server's min-1 traceIds rejection (as in the v3 traces table).- // Page selection needs concrete trace IDs.+ // Select-all is not gated on the visible-page selection: the+ // batch path deletes by query and ignores traceIds. Page+ // selection needs concrete trace IDs.disabled: selectAll? hasCommentFilter: selectedTraceIds.length === 0,diff --git a/web/src/server/api/routers/traces.ts b/web/src/server/api/routers/traces.tsindex fb5e3c8f94..4432e2a61c 100644--- a/web/src/server/api/routers/traces.ts+++ b/web/src/server/api/routers/traces.ts@@ -462,12 +462,24 @@ export const traceRouter = createTRPCRouter({}),deleteMany: protectedProjectProcedure.input(- z.object({- traceIds: z.array(z.string()).min(1, "Minimum 1 traceId is required."),- projectId: z.string(),- query: BatchActionQuerySchema.optional(),- isBatchAction: z.boolean().default(false),- }),+ z+ .object({+ traceIds: z.array(z.string()),+ projectId: z.string(),+ query: BatchActionQuerySchema.optional(),+ isBatchAction: z.boolean().default(false),+ })+ // Batch actions delete by query and ignore traceIds, so an empty list+ // is valid there (paging/refetch can drain the visible selection while+ // select-all is armed); only id-based deletes need at least one id.+ .refine((input) => input.isBatchAction || input.traceIds.length > 0, {+ message: "Minimum 1 traceId is required.",+ path: ["traceIds"],+ })+ .refine((input) => !input.isBatchAction || input.query !== undefined, {+ message: "Batch actions require a query.",+ path: ["query"],+ }),).mutation(async ({ input, ctx }) => {throwIfNoProjectAccess({