Repository navigation
fix(combinators): Handle equations in migration - #126768
Conversation
wmak
commented
Oct 7, 2026
- Wasn't handling equations in the migration so it'd hit an equation and fail
- Fixes SENTRY-5XR5
- Wasn't handling equations in the migration so it'd hit an equation and fail - Fixes SENTRY-5XR5
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 27575e1. Configure here.
| continue | ||
| if (rewritten := _rewrite_if_aggregate(func)) is not None: | ||
| updated = updated.replace(func, rewritten) | ||
| changed = True |
There was a problem hiding this comment.
Substring replace corrupts equation rewrites
High Severity
updated.replace rewrites every occurrence of each _if function string. When one function text is a prefix of another, the shorter match also rewrites the longer call, so the saved equation is corrupted. This migration is one-way, so the damaged query is persisted.
Reviewed by Cursor Bugbot for commit 27575e1. Configure here.
| equation: str, | ||
| max_operators: int | None = None, | ||
| validate_single_operator: bool = False, |
There was a problem hiding this comment.
Bug: The data migration silently skips equations that fail to parse, which could result in an incomplete migration with no audit trail.
Severity: MEDIUM
Suggested Fix
Add logging within the except block to record which specific equations failed to parse and why. This will create an audit trail, allowing developers to identify and manually fix any equations that were not automatically migrated.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/sentry/explore/migrations/0016_update_if_syntax_on_spans.py#L299-L301
Potential issue: In the data migration script, equations that fail to parse due to
invalid functions, fields, or syntax are caught and silently skipped by returning
`None`. This prevents the migration from crashing but can lead to an incomplete
migration. Some equations might remain in their old format in the database without any
log or notification indicating that they were not migrated. This lack of an audit trail
for failed transformations is problematic for data integrity.
Did we get this right? 👍 / 👎 to inform future reviews.

