Skip to content

Conversation

shahargl
Copy link
Member

close #5086

Fix CEL severity comparisons in workflows to use numeric values instead of lexicographic strings.

Previously, CEL expressions like severity > 'info' were evaluated lexicographically (e.g., 'high' < 'info') and caused type errors when compared to preprocessed numeric values. This PR ensures both the CEL expression and the alert's severity value are converted to their numeric order (e.g., high (4) > info (2)) before evaluation, resolving incorrect filtering and type errors.

- Add preprocess_cel_expression import to workflowmanager.py
- Apply severity preprocessing before CEL compilation to convert string
  comparisons like 'severity > "info"' to numeric comparisons
- This fixes the bug where 'high' < 'info' lexicographically but
  high (4) > info (2) numerically
- Add comprehensive tests for severity comparisons in workflows

Fixes #5086
- Convert alert severity string values to numeric order before CEL evaluation
- This ensures compatibility with preprocessed CEL expressions that convert
  severity comparisons like 'severity > "info"' to 'severity > 2'
- Prevents TypeError when comparing StringType with IntType in CEL evaluation
- Matches the approach used in rules engine for consistent behavior across the system

This completes the fix for GitHub issue #5086 where severity comparisons
in workflow CEL expressions were failing due to lexicographic vs numeric comparison.
@vercel
Copy link

vercel bot commented Jun 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
keep ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2025 7:40pm

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Bug Something isn't working labels Jun 25, 2025
Copy link
Member

@talboren talboren left a comment

Choose a reason for hiding this comment

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

lgtm

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 25, 2025
@shahargl shahargl merged commit a2533b6 into main Jun 25, 2025
18 checks passed
@shahargl shahargl deleted the cursor/fix-severity-handling-bug-in-cel-2944 branch June 25, 2025 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: CEL expression evaluation in workflows

3 participants