Skip to content

Commit 57e3c2b

Browse files
colegottdankclaude
andcommitted
fix: alert filter validation for property conditions
When creating filters on custom properties, the column should be "properties" with the property name in the "key" field. Previously the filter was incorrectly setting the property name as the column directly. Also added backward compatibility for existing filters that used the old format. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1f2e3d9 commit 57e3c2b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

web/filterAST/components/FilterConditionNode.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,18 @@ export const FilterConditionNode: React.FC<FilterConditionNodeProps> = ({
199199
})();
200200

201201
// Create updated condition with new field and default operator
202+
// For property and score subtypes, the column should be "properties" or "scores"
203+
// and the actual field name goes in the "key" property
204+
const isPropertyOrScore = filterDef.subType === "property" || filterDef.subType === "score";
202205
const updated: ConditionExpression = {
203206
...condition,
204207
field: {
205-
column: fieldId as any, // Use 'any' to bypass type checking temporarily
208+
column: isPropertyOrScore
209+
? (filterDef.subType === "property" ? "properties" : "scores") as any
210+
: fieldId as any,
206211
subtype: filterDef.subType,
207212
table: filterDef.table,
213+
...(isPropertyOrScore && { key: fieldId, valueMode: "value" as const }),
208214
},
209215
operator: defaultOperator,
210216
value: defaultValue, // Reset value since field changed
@@ -240,7 +246,13 @@ export const FilterConditionNode: React.FC<FilterConditionNodeProps> = ({
240246
};
241247

242248
// Find the filter definition for this field
243-
const filterDef = filterDefs.find((def) => def.id === condition.field.column);
249+
// For property/score subtypes, look up by the key field, otherwise by column
250+
// Handle backward compatibility: old filters may have property name in column instead of key
251+
const isPropertyOrScoreSubtype = condition.field.subtype === "property" || condition.field.subtype === "score";
252+
const filterDefId = isPropertyOrScoreSubtype
253+
? (condition.field.key || condition.field.column) // fallback to column for backward compatibility
254+
: condition.field.column;
255+
const filterDef = filterDefs.find((def) => def.id === filterDefId);
244256

245257
// Get available operators
246258
const operators = filterDef?.operators || [];
@@ -410,7 +422,7 @@ export const FilterConditionNode: React.FC<FilterConditionNodeProps> = ({
410422
>
411423
<SearchableSelect
412424
options={fieldOptions}
413-
value={condition.field.column}
425+
value={filterDefId}
414426
onValueChange={handleFieldChange}
415427
placeholder="Select field"
416428
searchPlaceholder="Search field..."

0 commit comments

Comments
 (0)