feat(events): Add a log for query errors#116696
Conversation
wmak
commented
Jun 2, 2026
- As ai usage increases we're getting more query errors, log these so we can get a better idea of what kind of query errors are happening
- As ai usage increases we're getting more query errors, log these so we can get a better idea of what kind of query errors are happening
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 800521c. Configure here.
| sentry_sdk.set_tag("query.error_reason", message) | ||
| message = "Project in query does not exist or not selected" | ||
| sentry_sdk.set_tag("query.error_reason", message) | ||
| logger.info(message) |
There was a problem hiding this comment.
User-supplied search query values logged via logger.info
The InvalidSearchQuery error message—built from str(error)—frequently embeds the raw user-typed query value (e.g. user.email:alice@corp.com → "user.email: Invalid date: alice@corp.com. ..."). Logging this with logger.info(message) sends that value to a durable application-log sink. Replace with a fixed categorical string or log only type(error).__name__ and omit the user-supplied value.
Evidence
message = str(error)(line 371) captures the fullInvalidSearchQuerystring verbatim.- In
event_search.py(_handle_basic_filter), errors are raised asf"{search_key.name}: Invalid date: {search_value.raw_value}. ..."—raw_valueis the literal text from the user's search bar. - A user searching
user.email:victim@company.comwith an invalid format would produce an error whose string contains the email address. sentry_sdk.set_tag("query.error_reason", message)already existed before this PR;logger.info(message)on line 377 is the only new durable sink introduced by this diff.- Application logs are typically retained and may be forwarded to third-party log aggregators, making this a broader exposure than the existing Sentry tag.
Identified by Warden wrdn-pii · Z5F-6NG
There was a problem hiding this comment.
Fix attempt detected (commit 5d74bfd)
The logger.info call was modified to use a static message with the user-derived value moved to extra, but extra={'query.error_reason': message} still embeds the raw user-supplied query string into the durable log record, so the PII exposure persists.
The original issue appears unresolved. Please review and try again.
Evaluated by Warden
| message = "Project in query does not exist or not selected" | ||
| sentry_sdk.set_tag("query.error_reason", message) | ||
| logger.info("A query error was handled", extra={"query.error_reason": message}) | ||
| raise ParseError(detail=original_error) |
