Skip to content

fix: alert filter validation for property conditions#5631

Open
colegottdank wants to merge 1 commit intomainfrom
fix/alert-filter-validation
Open

fix: alert filter validation for property conditions#5631
colegottdank wants to merge 1 commit intomainfrom
fix/alert-filter-validation

Conversation

@colegottdank
Copy link
Collaborator

Summary

  • Fixed alert filter validation error when filtering by custom properties
  • 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, causing validation errors

Test plan

  • Create an alert with a property filter (e.g., filter by product = "mintlify-workflow")
  • Verify the alert is created successfully without validation errors
  • Verify existing alerts with property filters still load correctly

🤖 Generated with Claude Code

@vercel
Copy link

vercel bot commented Mar 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
helicone Error Error Mar 7, 2026 3:06am
helicone-eu Error Error Mar 7, 2026 3:06am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
helicone-bifrost Skipped Skipped Mar 7, 2026 3:06am

Request Review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@supabase
Copy link

supabase bot commented Mar 7, 2026

This pull request has been ignored for the connected project bolqqmqbrciybnypvklh because there are no changes detected in supbase/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@supabase
Copy link

supabase bot commented Mar 7, 2026

This pull request has been ignored for the connected project lmahfbbnchpworytrrqk because there are no changes detected in .supabase/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@claude
Copy link
Contributor

claude bot commented Mar 7, 2026

Claude finished @colegottdank's task —— View job


Code Review Complete ✅

Todo List:

  • Read and analyze the 3 changed files
  • Review code for bugs, security issues, and performance problems
  • Check code quality and best practices
  • Provide specific suggestions with confidence score
  • Complete review feedback

Review Feedback

Score: 8/10 - Good fix with solid implementation, minor improvements suggested

Summary

This PR correctly fixes the alert filter validation issue for custom properties. The core problem was that property filters need to use "properties" as the column with the property name stored in the key field, rather than setting the property name as the column directly.

Code Analysis

What the fix does correctly:

  1. Proper column handling: web/filterAST/components/FilterConditionNode.tsx:206 - Uses filterDef.column ?? fieldId to get the correct column name ("properties" for custom properties)
  2. Conditional key assignment: web/filterAST/components/FilterConditionNode.tsx:209 - Only adds key and valueMode for property/score subtypes
  3. Correct field lookup: web/filterAST/components/FilterConditionNode.tsx:245 - Uses condition.field.key || condition.field.column to find the right filter definition
  4. Schema extension: web/filterAST/filterUIDefinitions/types.ts:8 - Adds optional column field to support this pattern
  5. Property configuration: web/filterAST/filterUIDefinitions/useFilterUIDefinitions.ts:87 - Sets column: "properties" for dynamic property definitions

Suggestions for Improvement

1. Type Safety Enhancement

File: web/filterAST/components/FilterConditionNode.tsx:206

// Current: Uses 'any' to bypass type checking
column: (filterDef.column ?? fieldId) as any,

// Suggested: More specific typing
column: (filterDef.column ?? fieldId) as FieldSpec["column"],

2. Code Clarity

File: web/filterAST/components/FilterConditionNode.tsx:202-203

// Current: Inline check  
const needsKey = filterDef.subType === "property" || filterDef.subType === "score";

// Consider: More descriptive variable name
const isPropertyOrScoreField = filterDef.subType === "property" || filterDef.subType === "score";

3. Documentation Enhancement

Add JSDoc comment to explain the complex property handling logic:

/**
 * Create updated condition with proper column and key handling.
 * For properties and scores, we use "properties"/"scores" as column
 * with the actual property name stored in the key field.
 */
const isPropertyOrScoreField = filterDef.subType === "property" || filterDef.subType === "score";

Positive Aspects

  1. Backward Compatibility: The fallback logic condition.field.key || condition.field.column ensures existing filters continue to work
  2. Consistent Implementation: All three files work together cohesively to implement the fix
  3. Proper Abstraction: The FilterUIDefinition.column field allows different field types to specify their database column
  4. Clean Conditional Logic: Only adds key and valueMode when actually needed

Database Schema Validation

From the codebase analysis, I can see that:

  • ClickHouse stores properties as Map(LowCardinality(String), String) with indexes on mapKeys(properties) and mapValues(properties)
  • The backend expects property queries using syntax like properties['property-name']
  • This PR correctly implements the UI to generate these structures

Security & Performance

No security issues detected
Performance impact is minimal - the changes are mainly structural
No breaking changes - existing functionality preserved

Minor Edge Case

Consider handling the case where filterDef.column is an empty string (though unlikely):

column: (filterDef.column || fieldId) as any,

Suggestions Summary:

  • Remove as any type assertion for better type safety
  • Consider more descriptive variable naming
  • Add JSDoc documentation for complex property handling logic
  • Handle empty string edge case for filterDef.column

The fix properly addresses the core issue and maintains good code quality. The implementation correctly follows the database schema requirements for property filtering.


Property filter definitions now explicitly set column: "properties".
FilterConditionNode uses filterDef.column ?? fieldId.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant