-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(hogql): better errors #15001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(hogql): better errors #15001
Conversation
posthog/hogql/ast.py
Outdated
@@ -32,12 +33,12 @@ def accept(self, visitor): | |||
return visit(self) | |||
if hasattr(visitor, "visit_unknown"): | |||
return visitor.visit_unknown(self) | |||
raise ValueError(f"Visitor has no method {method_name}") | |||
raise HogQLException(f"Visitor has no method {method_name}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this should be a NotImplementedException
?
posthog/hogql/errors.py
Outdated
@@ -0,0 +1,14 @@ | |||
class HogQLException(ValueError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be somewaht pedantic, I'm not sure if all HogQL exceptions are ValueError
s in the "Raised when an operation or function receives an argument that has the right type but an inappropriate value" sense – e.g. a "NotImplementedException" results not from an inappropriate value, but from our transient lack of support for a value that is appropriate in principle.
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good (also made a few tweaks)!
One gripe I have is that we're using HogQLException
very broadly, we might want to be more specific, particularly in a "this should be user facing" vs. "this is an internal problem" way. But will leave that for later PRs.
Problem
HogQL gives no errors and you have to play a guessing game to fix your query.
Changes
Instead of nothing, we now get some errors in the events explorer:
And in full SQL insights.
Unfortunately errors for "old insights" are still shown just in the network request:
I'm out of time to add support for nice errors in the interface for old insights, and it feels like something that will require custom handling with "project data exploration" anyway, so hoping @thmsobrmlr or @Twixes can help get this over the line...
While this could be added, this PR should be fine to merge already as is, because these errors will already help a lot of users.
One final point: Sometimes you can write valid HogQL, but still get a ClickHouse error. In that case, we currently show nothing. This will likely need followup as well. We should also allow-list clickhouse error codes and not send any potentially sensitive information. This closed PR implemented support for ClickHouse errors. It can be used as a starting point when implementing that.
How did you test this code?
Quickly tested in the browser (see screencasts).