Skip to content

Conversation

@thmsobrmlr
Copy link
Collaborator

Problem

We emit a "query executed" event but the has_error property is always false/null, making it unusable for a Product analytics health dashboard.

Changes

  • The only place that sets has_error is the success path in posthog/hogql_queries/query_runner.py (lines 1179-1224): after calculate() returns, it looks at fresh_response_dict.get("error") and emits posthoganalytics.capture("query executed", has_error=…). If calculate() throws (syntax errors, CH errors, ACL errors, etc.), we leave this block and re-raise, so no event is captured. That’s why you see zero has_error: true entries—the failures never reach the logging.
  • The cache-hit path (query_runner.py around 1030) also fires query executed but doesn’t include has_error at all, so cached failures wouldn’t surface either.
  • On top of that, most query runners raise on errors instead of populating an error field in the response; the code only checks the singular error key, not errors, so even responses that carry an errors array wouldn’t flip the flag.

If you want reliable failure tracking, you’ll need to wrap the calculate() call (and possibly the cached path) in a try/except, capture a query executed event with has_error=True before re-raising, and/or also look at errors in the response.

How did you test this code?

CI run

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.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

2 participants