posthog icon indicating copy to clipboard operation
posthog copied to clipboard

fix(debug): return things if results failed

Open mariusandra opened this issue 1 year ago β€’ 2 comments

Problem

If the query fails and returns None for results, we should still get back the HogQL query output and whatever else we got.

Sentry issue

ValidationError
1 validation error for HogQLQueryResponse
results
  Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.5/v/list_type

Changes

None or []

How did you test this code?

Didn't really, hoping it works.

mariusandra avatar May 06 '24 12:05 mariusandra

πŸ” Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

πŸ“„ File: posthog/hogql/query.py

Function Unhandled Issue
execute_hogql_query CHQueryErrorUnknownIdentifier: DB::Exception: Missing columns: '--events__override.distinct_id' '--events__override.person_id'... ...
Event Count: 2.3k
execute_hogql_query CHQueryErrorNoCommonType: DB::Exception: There is no supertype for types String, Float64 because some of them are String/Fi... ...
Event Count: 180
execute_hogql_query CHQueryErrorTypeMismatch: DB::Exception: Cannot convert string 17.4.1 to type Float64: while executing 'FUNCTION equals(toF... ...
Event Count: 152
execute_hogql_query CHQueryErrorIllegalTypeOfArgument: DB::Exception: Illegal type String of argument for aggregate function avg. Stack trace: ...
Event Count: 108
execute_hogql_query ValidationError: 1 validation error for HogQLQueryResponse posthog.tasks.tasks.process_...
Event Count: 86

Did you find this useful? React with a πŸ‘ or πŸ‘Ž

sentry-io[bot] avatar May 06 '24 12:05 sentry-io[bot]

This change concerns results not result πŸ˜… πŸ™ˆ.

Alternatively I'll make results optional/nullable in the type, which is probably the right thing anyway.

mariusandra avatar May 06 '24 14:05 mariusandra

Thinking this through, making results optional here will make results optional for all data nodes:

https://github.com/PostHog/posthog/blob/add62bedade42ccf4302f3e7c3ec058672c86640/frontend/src/queries/schema.ts#L899-L900

This change here is only for debug mode, where we want to return incomplete results if the query errors. It seems a bit excessive to add ?. to a lot of places in the frontend that deal with any kind of resultsΒ just for this.

So I moved the [] line up a bit to make it more clear that it's an one off. Would this be fine?

mariusandra avatar May 07 '24 08:05 mariusandra