πͺ’ 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(traces): fix v4 search query & filters (#12660)
Thorsten Spiekerf449e66a36a3
diff --git a/packages/shared/src/server/repositories/events.ts b/packages/shared/src/server/repositories/events.tsindex e9552d30ad..41c858b6a0 100644--- a/packages/shared/src/server/repositories/events.ts+++ b/packages/shared/src/server/repositories/events.ts@@ -447,7 +447,7 @@ async function getObservationsFromEventsTableInternal<T>(opts.searchQuery,opts.searchType,"e",- ["span_id", "name", "user_id", "session_id", "trace_id"],+ ["span_id", "name", "trace_name", "user_id", "session_id", "trace_id"],);const orderByEntries = orderByToEntries(diff --git a/packages/shared/src/server/tableMappings/mapTracesTable.ts b/packages/shared/src/server/tableMappings/mapTracesTable.tsindex 58bd0aaf6f..d3fe572fba 100644--- a/packages/shared/src/server/tableMappings/mapTracesTable.ts+++ b/packages/shared/src/server/tableMappings/mapTracesTable.ts@@ -99,6 +99,14 @@ export const tracesTableUiColumnDefinitions: UiColumnMappings = [clickhouseSelect: "tags",queryPrefix: "t",},+ {+ // Alias for tags so canonical traceTags filters work on the traces table too.+ uiTableName: "Trace Tags",+ uiTableId: "traceTags",+ clickhouseTableName: "traces",+ clickhouseSelect: "tags",+ queryPrefix: "t",+ },{uiTableName: "Warning Level Count",uiTableId: "warningCount",diff --git a/packages/shared/src/tableDefinitions/tracesTable.ts b/packages/shared/src/tableDefinitions/tracesTable.tsindex 4b94240330..dfe8c938fd 100644--- a/packages/shared/src/tableDefinitions/tracesTable.ts+++ b/packages/shared/src/tableDefinitions/tracesTable.ts@@ -16,11 +16,12 @@ export const tracesOnlyCols: ColumnDefinition[] = [{ name: "ID", id: "id", type: "string", internal: "t.id" },{name: "Name",- id: "name",+ id: "traceName",type: "stringOptions",internal: 't."name"',options: [], // to be filled in at runtimenullable: true,+ aliases: ["name"],},{name: "Environment",@@ -83,10 +84,11 @@ export const tracesOnlyCols: ColumnDefinition[] = [},{name: "Tags",- id: "tags",+ id: "traceTags",type: "arrayOptions",internal: 't."tags"',options: [], // to be filled in at runtime+ aliases: ["tags"],},];export const tracesTableCols: ColumnDefinition[] = [@@ -215,8 +217,8 @@ export const evalDatasetFormFilterCols: ColumnDefinition[] = datasetOnlyCols;export type TraceOptions = {scores_avg?: Array<string>;score_categories?: Array<MultiValueOption>;- name?: Array<SingleValueOption>;- tags?: Array<SingleValueOption>;+ traceName?: Array<SingleValueOption>;+ traceTags?: Array<SingleValueOption>;environment?: Array<SingleValueOption>;};export type DatasetOptions = {@@ -244,11 +246,11 @@ export function tracesTableColsWithOptions(if (col.id === "scores_avg") {return formatColumnOptions(col, options?.scores_avg ?? []);}- if (col.id === "name") {- return formatColumnOptions(col, options?.name ?? []);+ if (col.id === "traceName") {+ return formatColumnOptions(col, options?.traceName ?? []);}- if (col.id === "tags") {- return formatColumnOptions(col, options?.tags ?? []);+ if (col.id === "traceTags") {+ return formatColumnOptions(col, options?.traceTags ?? []);}if (col.id === "environment") {return formatColumnOptions(col, options?.environment ?? []);diff --git a/packages/shared/src/tableDefinitions/types.ts b/packages/shared/src/tableDefinitions/types.tsindex 03f850644e..7116fe943e 100644--- a/packages/shared/src/tableDefinitions/types.ts+++ b/packages/shared/src/tableDefinitions/types.ts@@ -30,6 +30,7 @@ export type ColumnDefinition =type: "number" | "string" | "datetime" | "boolean" | "null";internal: string;nullable?: boolean;+ aliases?: string[];/** Step for number inputs (e.g. 1 for integers). Defaults to 0.01 in UI. */step?: number;/** Minimum value for number inputs. */@@ -41,6 +42,7 @@ export type ColumnDefinition =type: "positionInTrace";internal: string;nullable?: boolean;+ aliases?: string[];}| {name: string;@@ -49,6 +51,7 @@ export type ColumnDefinition =options: Array<SingleValueOption>;internal: string;nullable?: boolean;+ aliases?: string[]; // Used for backward compatibility with legacy column names, e.g. "traces.name" β "traces.traceName"}| {name: string;@@ -57,6 +60,7 @@ export type ColumnDefinition =options: Array<SingleValueOption>;internal: string;nullable?: boolean;+ aliases?: string[];}| {name: string;@@ -65,6 +69,7 @@ export type ColumnDefinition =internal: string;keyOptions?: Array<string>;nullable?: boolean;+ aliases?: string[];}| {name: string;@@ -73,6 +78,7 @@ export type ColumnDefinition =options: Array<MultiValueOption>;internal: string;nullable?: boolean;+ aliases?: string[];};export const tableNames = [diff --git a/web/src/__tests__/table-view-presets.clienttest.ts b/web/src/__tests__/table-view-presets.clienttest.tsindex 3f4f974a2d..08a4bcd803 100644--- a/web/src/__tests__/table-view-presets.clienttest.ts+++ b/web/src/__tests__/table-view-presets.clienttest.ts@@ -11,14 +11,34 @@ import {// Mock data for testingconst mockColumns = [{ id: "name", enableSorting: true, accessorKey: "name" },+ { id: "traceName", enableSorting: true, accessorKey: "traceName" },{ id: "status", enableSorting: true, accessorKey: "status" },{ id: "age", enableSorting: false, accessorKey: "age" },];+const mockTraceTableColumns = [+ { id: "name", enableSorting: true, accessorKey: "name" },+ { id: "status", enableSorting: true, accessorKey: "status" },+];+const mockFilterDefinitions: ColumnDefinition[] = [- { id: "name", name: "name", type: "string", internal: "name" },+ {+ id: "traceName",+ name: "Name",+ type: "string",+ internal: "name",+ aliases: ["name"],+ },{ id: "status", name: "status", type: "string", internal: "status" },{ id: "city", name: "city", type: "string", internal: "city" },+ {+ id: "traceTags",+ name: "Tags",+ type: "arrayOptions",+ internal: "tags",+ options: [],+ aliases: ["tags"],+ },];describe("table view presets validation functions", () => {@@ -36,6 +56,16 @@ describe("table view presets validation functions", () => {expect(validateOrderBy(orderBy, mockColumns)).toEqual(orderBy);});+ it("should normalize legacy orderBy columns via aliases", () => {+ const orderBy: OrderByState = { column: "traceName", order: "ASC" };+ expect(+ validateOrderBy(orderBy, mockTraceTableColumns, mockFilterDefinitions),+ ).toEqual({+ column: "name",+ order: "ASC",+ });+ });+it("should return null if column does not exist", () => {const orderBy: OrderByState = { column: "nonexistent", order: "ASC" };expect(validateOrderBy(orderBy, mockColumns)).toBeNull();@@ -80,7 +110,7 @@ describe("table view presets validation functions", () => {{type: "string",value: "John",- column: "name",+ column: "traceName",operator: "=",},];@@ -92,7 +122,7 @@ describe("table view presets validation functions", () => {{type: "string",value: "John",- column: "name",+ column: "traceName",operator: "=",},{@@ -105,6 +135,38 @@ describe("table view presets validation functions", () => {expect(validateFilters(filters, mockFilterDefinitions)).toEqual(filters);});+ it("should normalize legacy aliases to canonical trace filter ids", () => {+ const filters: FilterState = [+ {+ type: "string",+ value: "John",+ column: "name",+ operator: "=",+ },+ {+ type: "arrayOptions",+ value: ["prod"],+ column: "tags",+ operator: "any of",+ },+ ];++ expect(validateFilters(filters, mockFilterDefinitions)).toEqual([+ {+ type: "string",+ value: "John",+ column: "traceName",+ operator: "=",+ },+ {+ type: "arrayOptions",+ value: ["prod"],+ column: "traceTags",+ operator: "any of",+ },+ ]);+ });+it("should return empty array if no filters are valid", () => {const filters: FilterState = [{diff --git a/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts b/web/src/components/table/table-view-presets/hooks/useTableViewManager.tsindex 93f558bcca..cf03a1f7e3 100644--- a/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts+++ b/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts@@ -196,6 +196,7 @@ export function useTableViewManager({validOrderBy = validateOrderBy(viewData.orderBy,validationContext.columns,+ validationContext.filterColumnDefinition,);}diff --git a/web/src/components/table/table-view-presets/validation.ts b/web/src/components/table/table-view-presets/validation.tsindex 3ce4e95647..ceee4d0e37 100644--- a/web/src/components/table/table-view-presets/validation.ts+++ b/web/src/components/table/table-view-presets/validation.ts@@ -7,19 +7,41 @@ import {import { normalizeFilterColumnNames } from "@/src/features/filters/lib/filter-transform";/**- * Validates if an orderBy state references valid columns+ * Validates if an orderBy state references valid columns.+ * Normalizes legacy column IDs (e.g. "name" β "traceName") via aliases.*/export function validateOrderBy(orderBy: OrderByState | null,columns?: LangfuseColumnDef<any, any>[],+ filterColumnDefinitions?: ColumnDefinition[],): OrderByState | null {if (!orderBy || !columns || columns.length === 0) return null;- // Check if the column exists and supports sorting- const isValid = columns.some(- (col) => col.id === orderBy.column && col.enableSorting !== false,- );- return isValid ? orderBy : null;+ const isSortableColumn = (columnId: string) =>+ columns.some((col) => col.id === columnId && col.enableSorting !== false);++ // If the column already exists in the active table, keep it.+ if (isSortableColumn(orderBy.column)) {+ return orderBy;+ }++ // Resolve legacy/canonical IDs via filter-layer aliases (e.g. "name" β "traceName")+ let resolvedColumn: string | null = null;+ if (filterColumnDefinitions) {+ const colDef = filterColumnDefinitions.find(+ (c) =>+ c.id === orderBy.column ||+ c.name === orderBy.column ||+ c.aliases?.includes(orderBy.column),+ );+ if (colDef) {+ const candidates = [colDef.id, ...(colDef.aliases ?? [])];+ resolvedColumn =+ candidates.find((candidate) => isSortableColumn(candidate)) ?? null;+ }+ }++ return resolvedColumn ? { ...orderBy, column: resolvedColumn } : null;}/**@@ -52,9 +74,8 @@ export function validateFilters();// Validate that columns exist (remove invalid ones)+ // After normalization, filter.column is always a canonical IDreturn normalized.filter((filter) => {- return filterColumnDefinition.some(- (def) => def.id === filter.column || def.name === filter.column,- );+ return filterColumnDefinition.some((def) => def.id === filter.column);});}diff --git a/web/src/components/table/use-cases/traces.tsx b/web/src/components/table/use-cases/traces.tsxindex 2ab4599a70..659098861e 100644--- a/web/src/components/table/use-cases/traces.tsx+++ b/web/src/components/table/use-cases/traces.tsx@@ -291,13 +291,13 @@ export default function TracesTable({traceFilterOptionsResponse.data?.scores_avg ?? undefined;return {- name:+ traceName:traceFilterOptionsResponse.data?.name?.map((n) => ({value: n.value,count: Number(n.count),})) ?? undefined,// tags don't have counts- tags:+ traceTags:traceFilterOptionsResponse.data?.tags?.map((t) => t.value) ?? undefined,environment:environmentFilterOptions.data?.map((value) => value.environment) ??@@ -1321,7 +1321,7 @@ export default function TracesTable({setSearchType,searchType,}}- columnsWithCustomSelect={["name", "tags"]}+ columnsWithCustomSelect={["traceName", "traceTags"]}actionButtons={[Object.keys(selectedRows).filter((traceId) =>traces.data?.traces.map((t) => t.id).includes(traceId),diff --git a/web/src/features/evals/components/inner-evaluator-form.tsx b/web/src/features/evals/components/inner-evaluator-form.tsxindex 7b88af4edc..642ec90509 100644--- a/web/src/features/evals/components/inner-evaluator-form.tsx+++ b/web/src/features/evals/components/inner-evaluator-form.tsx@@ -1026,9 +1026,11 @@ export const InnerEvaluatorForm = (props: {}}disabled={props.disabled}columnsWithCustomSelect={- isEventTarget(target) || isTraceTarget(target)- ? ["tags", "name", "calledToolNames"]- : undefined+ isTraceTarget(target)+ ? ["traceTags", "traceName"]+ : isEventTarget(target)+ ? ["tags", "name", "calledToolNames"]+ : undefined}/>)}diff --git a/web/src/features/evals/hooks/useEvalConfigFilterOptions.ts b/web/src/features/evals/hooks/useEvalConfigFilterOptions.tsindex e22889fdf9..9fd8301eb6 100644--- a/web/src/features/evals/hooks/useEvalConfigFilterOptions.ts+++ b/web/src/features/evals/hooks/useEvalConfigFilterOptions.ts@@ -45,13 +45,13 @@ export function useEvalConfigFilterOptions({// Normalize API response to match TraceOptions type (count should be number, not string)const normalized = traceFilterOptionsResponse.data? {- name: traceFilterOptionsResponse.data.name?.map((n) => ({+ traceName: traceFilterOptionsResponse.data.name?.map((n) => ({value: n.value,count: Number(n.count),})),scores_avg: traceFilterOptionsResponse.data.scores_avg,score_categories: traceFilterOptionsResponse.data.score_categories,- tags: traceFilterOptionsResponse.data.tags?.map((t) => ({+ traceTags: traceFilterOptionsResponse.data.tags?.map((t) => ({value: t.value,})),}diff --git a/web/src/features/evals/utils/evaluator-constants.ts b/web/src/features/evals/utils/evaluator-constants.tsindex 218ad6a6c5..57e716216b 100644--- a/web/src/features/evals/utils/evaluator-constants.ts+++ b/web/src/features/evals/utils/evaluator-constants.ts@@ -24,6 +24,7 @@ export const OBSERVATION_VARIABLES = [export const COLUMN_IDENTIFIERS_THAT_REQUIRE_PROPAGATION = new Set(["release","traceName",+ "traceTags","userId","sessionId","tags",diff --git a/web/src/features/filters/components/filter-builder.tsx b/web/src/features/filters/components/filter-builder.tsxindex 5e6d2f1c96..6479f4695f 100644--- a/web/src/features/filters/components/filter-builder.tsx+++ b/web/src/features/filters/components/filter-builder.tsx@@ -589,7 +589,11 @@ function FilterBuilderForm({<tbody>{filterState.map((filter, i) => {const column = columns.find(- (c) => c.id === filter.column || c.name === filter.column,+ (c) =>+ c.id === filter.column ||+ c.name === filter.column ||+ (filter.column !== undefined &&+ c.aliases?.includes(filter.column)),);return (<tr key={i}>diff --git a/web/src/features/filters/config/traces-config.ts b/web/src/features/filters/config/traces-config.tsindex 8d0789c7e5..334b10c0a3 100644--- a/web/src/features/filters/config/traces-config.ts+++ b/web/src/features/filters/config/traces-config.ts@@ -6,7 +6,7 @@ export const traceFilterConfig: FilterConfig = {columnDefinitions: tracesTableCols,- defaultExpanded: ["environment", "name"],+ defaultExpanded: ["environment", "traceName"],facets: [{@@ -16,7 +16,7 @@ export const traceFilterConfig: FilterConfig = {},{type: "categorical" as const,- column: "name",+ column: "traceName",label: "Trace Name",},{@@ -70,7 +70,7 @@ export const traceFilterConfig: FilterConfig = {},{type: "categorical" as const,- column: "tags",+ column: "traceTags",label: "Tags",},{diff --git a/web/src/features/filters/filter-integration.clienttest.ts b/web/src/features/filters/filter-integration.clienttest.tsindex 68684f1d11..f28c655eef 100644--- a/web/src/features/filters/filter-integration.clienttest.ts+++ b/web/src/features/filters/filter-integration.clienttest.ts@@ -307,9 +307,10 @@ describe("Saved View Validation (Backward & Forward Compatibility)", () => {// This is what useTableViewManager does: validates then appliesconst validated = validateFilters(oldSavedView, tracesTableCols);- // Should pass through unchanged - no env/timestamp to validate- expect(validated).toEqual(oldSavedView);+ // "name" is normalized to "traceName" via aliasexpect(validated).toHaveLength(2);+ expect(validated[0]?.column).toBe("traceName");+ expect(validated[1]?.column).toBe("latency");});it("should save new view with environment filter and restore it correctly", () => {@@ -335,10 +336,10 @@ describe("Saved View Validation (Backward & Forward Compatibility)", () => {// 2. RESTORE: Later, load from database and validateconst validated = validateFilters(savedToDB, tracesTableCols);- // Should restore with environment filter intact- expect(validated).toEqual(newFilterState);+ // Should restore with environment filter intact, "name" normalized to "traceName"expect(validated).toHaveLength(2);expect(validated[0]?.column).toBe("environment"); // β Environment preserved+ expect(validated[1]?.column).toBe("traceName"); // Normalized via alias});it("should save new view with timestamp filter and restore it correctly", () => {@@ -367,10 +368,10 @@ describe("Saved View Validation (Backward & Forward Compatibility)", () => {// SAVE β RESTORE cycleconst validated = validateFilters(newFilterState, tracesTableCols);- // Should restore with timestamp filters intact- expect(validated).toEqual(newFilterState);+ // Should restore with timestamp filters intact, "name" normalized to "traceName"expect(validated).toHaveLength(3);expect(validated[0]?.column).toBe("timestamp"); // β Timestamp preserved+ expect(validated[2]?.column).toBe("traceName"); // Normalized via alias});it("should demonstrate BUG: restore fails with filtered column definitions", () => {@@ -401,7 +402,7 @@ describe("Saved View Validation (Backward & Forward Compatibility)", () => {// BUG: environment filter incorrectly removed during restore!expect(validated).toHaveLength(1); // β Lost environment filter- expect(validated[0]?.column).toBe("name");+ expect(validated[0]?.column).toBe("traceName");// This would show error toast: "Outdated view - Some filters were ignored"});@@ -430,9 +431,12 @@ describe("Saved View Validation (Backward & Forward Compatibility)", () => {const validated = validateFilters(mixedView, tracesTableCols);- // Should remove deletedColumn, keep environment and name+ // Should remove deletedColumn, keep environment and name (name normalized to traceName via alias)expect(validated).toHaveLength(2);- expect(validated.map((f) => f.column)).toEqual(["environment", "name"]);+ expect(validated.map((f) => f.column)).toEqual([+ "environment",+ "traceName",+ ]);});it("should normalize old display names to column IDs", () => {@@ -454,10 +458,10 @@ describe("Saved View Validation (Backward & Forward Compatibility)", () => {const validated = validateFilters(oldViewWithDisplayNames, tracesTableCols);- // Should normalize "User ID" to "userId", keep "name" as-is+ // Should normalize "User ID" to "userId", normalize "name" to "traceName" via aliasexpect(validated).toHaveLength(2);expect(validated[0]?.column).toBe("userId"); // Normalized!- expect(validated[1]?.column).toBe("name"); // Already correct+ expect(validated[1]?.column).toBe("traceName"); // Normalized via alias!});it("should handle old saved view metadata filter with column name metadata key", () => {@@ -600,8 +604,7 @@ describe("Filter Flow: URL β Decode β Normalize β Transform", () => {});});- it("should handle backend column remapping from URL", () => {- // Observations/traces table: "tags" (frontend) β "traceTags" (ClickHouse backend)+ it("should normalize legacy tags filter from URL to the canonical traceTags column", () => {const urlFilter = "tags;arrayOptions;;any of;tag1";const normalized = decodeAndNormalizeFilters(@@ -609,9 +612,7 @@ describe("Filter Flow: URL β Decode β Normalize β Transform", () => {traceFilterConfig.columnDefinitions,);- const result = transformFiltersForBackend(normalized, {- tags: "traceTags",- });+ const result = transformFiltersForBackend(normalized, {});expect(result).toHaveLength(1);expect(result[0]?.column).toBe("traceTags");diff --git a/web/src/features/filters/hooks/useSidebarFilterState.tsx b/web/src/features/filters/hooks/useSidebarFilterState.tsxindex 3c0be2dc6b..d9a04f2c5c 100644--- a/web/src/features/filters/hooks/useSidebarFilterState.tsx+++ b/web/src/features/filters/hooks/useSidebarFilterState.tsx@@ -49,6 +49,10 @@ export function decodeAndNormalizeFilters(for (const columnDefinition of columnDefinitions) {knownColumns.set(columnDefinition.id, columnDefinition.id);knownColumns.set(columnDefinition.name, columnDefinition.id);+ // Map old column IDs to current canonical ID for backward compat+ for (const alias of columnDefinition.aliases ?? []) {+ knownColumns.set(alias, columnDefinition.id);+ }}// Normalize display names to column IDs immediately after decodingdiff --git a/web/src/features/filters/lib/filter-transform.ts b/web/src/features/filters/lib/filter-transform.tsindex 775e31f4f1..476b9499a1 100644--- a/web/src/features/filters/lib/filter-transform.ts+++ b/web/src/features/filters/lib/filter-transform.ts@@ -22,7 +22,10 @@ export function normalizeFilterColumnNames(): FilterState {return filters.map((filter) => {const colDef = columnDefinitions.find(- (c) => c.id === filter.column || c.name === filter.column,+ (c) =>+ c.id === filter.column ||+ c.name === filter.column ||+ c.aliases?.includes(filter.column),);if (colDef && colDef.id !== filter.column) {return { ...filter, column: colDef.id };diff --git a/worker/src/__tests__/evalService.test.ts b/worker/src/__tests__/evalService.test.tsindex 182d82f410..31969d09c9 100644--- a/worker/src/__tests__/evalService.test.ts+++ b/worker/src/__tests__/evalService.test.ts@@ -3031,13 +3031,24 @@ Respond with JSON: {"score": <number>, "reasoning": "<explanation>"}`;test("requiresDatabaseLookup correctly identifies complex filters", () => {// Simple filters that can be evaluated with trace data onlyconst simpleFilters = [- { column: "name", type: "string", operator: "=", value: "test-trace" },+ {+ column: "traceName",+ type: "string",+ operator: "=",+ value: "test-trace",+ },{column: "environment",type: "string",operator: "=",value: "production",},+ {+ column: "traceTags",+ type: "arrayOptions",+ operator: "any of",+ value: ["prod"],+ },{ column: "bookmarked", type: "boolean", operator: "=", value: true },];@@ -3052,7 +3063,12 @@ Respond with JSON: {"score": <number>, "reasoning": "<explanation>"}`;// Mixed filters - should return false if any filter requires observation dataconst mixedFilters = [- { column: "name", type: "string", operator: "=", value: "test-trace" },+ {+ column: "traceName",+ type: "string",+ operator: "=",+ value: "test-trace",+ },{ column: "level", type: "string", operator: "=", value: "ERROR" }, // This requires observation data];diff --git a/worker/src/features/database-read-stream/event-stream.ts b/worker/src/features/database-read-stream/event-stream.tsindex 674477cc13..75af6b85fb 100644--- a/worker/src/features/database-read-stream/event-stream.ts+++ b/worker/src/features/database-read-stream/event-stream.ts@@ -123,6 +123,7 @@ export const getEventsStream = async (props: {const search = clickhouseSearchCondition(searchQuery, searchType, "e", ["span_id","name",+ "trace_name","user_id","session_id","trace_id",@@ -400,6 +401,7 @@ export const getEventsStreamForEval = async (props: {const search = clickhouseSearchCondition(searchQuery, searchType, "e", ["span_id","name",+ "trace_name","user_id","session_id","trace_id",@@ -539,6 +541,7 @@ export const getEventsStreamForDataset = async (props: {const search = clickhouseSearchCondition(searchQuery, searchType, "e", ["span_id","name",+ "trace_name","user_id","session_id","trace_id",diff --git a/worker/src/features/evaluation/traceFilterUtils.ts b/worker/src/features/evaluation/traceFilterUtils.tsindex 932b31d49f..3f35a6c93c 100644--- a/worker/src/features/evaluation/traceFilterUtils.ts+++ b/worker/src/features/evaluation/traceFilterUtils.ts@@ -1,8 +1,7 @@import { FilterState, TraceDomain } from "@langfuse/shared";import { tracesTableUiColumnDefinitions } from "@langfuse/shared/src/server";-// Uses the uiTableId for mapping fields later.-const evalTraceFilterColumns = [+const _inMemoryTraceFilterColumns = ["id","bookmarked","name",@@ -16,6 +15,9 @@ const evalTraceFilterColumns = ["tags",] as const;+type InMemoryTraceFilterColumn = (typeof _inMemoryTraceFilterColumns)[number];++// Uses the uiTableId for mapping fields later.function getColumnDefinition(column: string) {const columnDef = tracesTableUiColumnDefinitions.find((col) =>@@ -29,6 +31,33 @@ function getColumnDefinition(column: string) {return columnDef;}+function getInMemoryTraceFilterColumn(+ column: string,+): InMemoryTraceFilterColumn | null {+ const columnDef = getColumnDefinition(column);++ switch (columnDef.uiTableId) {+ case "traceName":+ return "name";+ case "traceTags":+ return "tags";+ case "id":+ case "bookmarked":+ case "name":+ case "environment":+ case "timestamp":+ case "userId":+ case "sessionId":+ case "metadata":+ case "release":+ case "version":+ case "tags":+ return columnDef.uiTableId;+ default:+ return null;+ }+}+/*** Maps trace filter column names to trace object field values.* Uses the centralized table mapping to ensure consistency with UI column definitions.@@ -37,8 +66,12 @@ export function mapTraceFilterColumn(trace: TraceDomain,column: string,): unknown {- const columnDef = getColumnDefinition(column);- switch (columnDef.uiTableId) {+ const inMemoryColumn = getInMemoryTraceFilterColumn(column);+ if (!inMemoryColumn) {+ throw new Error(`Unhandled column in trace filter mapping: ${column}`);+ }++ switch (inMemoryColumn) {case "id":return trace.id;case "name":@@ -76,11 +109,7 @@ export function requiresDatabaseLookup(filter: FilterState): boolean {}for (const condition of filter) {- if (- !evalTraceFilterColumns.some(- (c) => c === getColumnDefinition(condition.column).uiTableId,- )- ) {+ if (!getInMemoryTraceFilterColumn(condition.column)) {return true;}}