posthog
posthog copied to clipboard
HogQL: More helpful error messages
Is your feature request related to a problem?
These messages are helpful
This message is not
Describe the solution you'd like
Return more helpful error messages. I know there are some security concerns here, but perhaps we can limit it to certain types of error codes or even have the HogQL parses realise these types of errors? I assume this might be part of the type system? @Gilbert09
Describe alternatives you've considered
Additional context
Thank you for your feature request – we love each and every one!
More context: We should add user_safe=True to all errors that are safe to show:
https://github.com/PostHog/posthog/blob/cdeb283151af43dced5f7e32ffd31c3967b6e231/posthog/errors.py#L342
We took the safe/cautious approach by default to avoid accidentally leaking anything...
I think this is now fixed by @mariusandra here: https://github.com/PostHog/posthog/pull/20292
@Gilbert09 I'm still getting this occasionally, where it looks like there are no results but there's actually an error
select sum(JSONExtractInt(line, 'quantity')) as invoiced_usage, customer_id
, mrr
-- max(tupleElement(period_start, 1)),
-- max(tupleElement(period_end, 1))
from (
select arrayJoin(JSONExtractArrayRaw(JSONExtractString(data, 'lines'), 'data')) as line, customer_id, JSONExtractInt(mrr_per_product, 'session_replay') as mrr, period_start, period_end
from invoice_with_annual
where JSONExtractInt(mrr_per_product, 'session_replay') > 0
and toStartOfMonth(tupleElement(period_end, 1)) = toStartOfMonth(now() - toIntervalMonth(1))
and JSONExtractString(line, 'price', 'nickname') LIKE '%session_replay%'
)
group by customer_id
Another issue. Note the group by 1, which isn't allowed and causes an exception in Clickhouse, but doesn't return the error in the API at all.
select sum(JSONExtractInt(line, 'quantity')) as invoiced_usage, customer_id
, mrr
-- max(tupleElement(period_start, 1)),
-- max(tupleElement(period_end, 1))
from (
select arrayJoin(JSONExtractArrayRaw(JSONExtractString(data, 'lines'), 'data')) as line, customer_id, JSONExtractInt(mrr_per_product, 'session_replay') as mrr, period_start, period_end
from invoice_with_annual
where JSONExtractInt(mrr_per_product, 'session_replay') > 0
and toStartOfMonth(tupleElement(period_end, 1)) = toStartOfMonth(now() - toIntervalMonth(1))
and JSONExtractString(line, 'price', 'nickname') LIKE '%session_replay%'
)
group by 1, customer_id
This simpler query gives me the same non-error locally:
select toDate(timestamp) as timestamp, count(), event
from events
where {filters} and timestamp <= now()
group by 1, timestamp
order by timestamp asc
limit 100
A fix is here: https://github.com/PostHog/posthog/pull/20611
I think we have this handled for a lot of cases