From 82263bd3403329ed205cb9d4e0f310bb75c0a33c Mon Sep 17 00:00:00 2001 From: Alexander Spicer Date: Tue, 10 Sep 2024 21:38:53 -0700 Subject: [PATCH] expose api errors --- posthog/clickhouse/client/execute_async.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/posthog/clickhouse/client/execute_async.py b/posthog/clickhouse/client/execute_async.py index 14e8cb4fae06d..88d479c8b331a 100644 --- a/posthog/clickhouse/client/execute_async.py +++ b/posthog/clickhouse/client/execute_async.py @@ -8,7 +8,7 @@ import sentry_sdk import structlog from prometheus_client import Histogram -from rest_framework.exceptions import NotFound +from rest_framework.exceptions import NotFound, APIException from posthog import celery, redis from posthog.clickhouse.client.async_task_chain import add_task_to_on_commit @@ -198,7 +198,7 @@ def execute_process_query( raise except Exception as err: query_status.results = None # Clear results in case they are faulty - if isinstance(err, ExposedHogQLError | ExposedCHQueryError) or is_staff_user: + if isinstance(err, APIException | ExposedHogQLError | ExposedCHQueryError) or is_staff_user: # We can only expose the error message if it's a known safe error OR if the user is PostHog staff query_status.error_message = str(err) logger.exception("Error processing query async", team_id=team_id, query_id=query_id, exc_info=True)