Skip to content

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

fix(filters): fallback to key input on empty key options (#13570)

Ben Bachemdc44c5f85416
diff --git a/web/src/features/filters/components/filter-builder.tsx b/web/src/features/filters/components/filter-builder.tsx
index 99599256d5..9236168028 100644
--- a/web/src/features/filters/components/filter-builder.tsx
+++ b/web/src/features/filters/components/filter-builder.tsx
@@ -601,6 +601,13 @@ function FilterBuilderForm({
(filter.column !== undefined &&
c.aliases?.includes(filter.column)),
);
+ const keyOptions =
+ column?.type === "numberObject" ||
+ column?.type === "stringObject"
+ ? column.keyOptions?.filter(
+ (o) => NonEmptyString.safeParse(o).success,
+ )
+ : undefined;
return (
<tr key={i}>
<td className="p-1 text-sm">{i === 0 ? "Where" : "And"}</td>
@@ -720,7 +727,7 @@ function FilterBuilderForm({
filter.type === "stringObject") &&
(column?.type === "numberObject" ||
column?.type === "stringObject") ? (
- column.keyOptions ? (
+ keyOptions?.length ? (
// Case 1: object with keyOptions - selector of the key of the object
<Select
disabled={!filter.column}
@@ -733,15 +740,11 @@ function FilterBuilderForm({
<SelectValue placeholder="" />
</SelectTrigger>
<SelectContent>
- {column.keyOptions
- .filter(
- (o) => NonEmptyString.safeParse(o).success,
- )
- .map((option) => (
- <SelectItem key={option} value={option}>
- {option}
- </SelectItem>
- ))}
+ {keyOptions.map((option) => (
+ <SelectItem key={option} value={option}>
+ {option}
+ </SelectItem>
+ ))}
</SelectContent>
</Select>
) : (