Skip to content

Commit

Permalink
improve error message on exceeding the max number of queries
Browse files Browse the repository at this point in the history
  • Loading branch information
orian committed Mar 4, 2025
1 parent 5188b7d commit 1764041
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions posthog/api/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ def create(self, request, *args, **kwargs) -> Response:
return Response(result, status=response_status)
except (ExposedHogQLError, ExposedCHQueryError) as e:
raise ValidationError(str(e), getattr(e, "code_name", None))
except ConcurrencyLimitExceeded:
raise Throttled()
except ConcurrencyLimitExceeded as c:
raise Throttled(detail=str(c))

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.
except Exception as e:
self.handle_column_ch_error(e)
capture_exception(e)
Expand Down
9 changes: 4 additions & 5 deletions posthog/clickhouse/client/limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ class RateLimit:

@contextmanager
def run(self, *args, **kwargs):
cleanup = None
if not self.applicable or self.applicable(*args, **kwargs):
applicable = not self.applicable or self.applicable(*args, **kwargs)
if applicable:
running_task_key, task_id = self.use(*args, **kwargs)
cleanup = True
try:
yield
finally:
if cleanup:
if applicable:
self.release(running_task_key, task_id)

def use(self, *args, **kwargs):
Expand All @@ -102,7 +101,7 @@ def use(self, *args, **kwargs):
).inc()

raise ConcurrencyLimitExceeded(
f"Exceeded maximum concurrent tasks limit: {self.max_concurrent_tasks} for key: {task_name} and task: {task_id}"
f"Exceeded maximum concurrency limit: {self.max_concurrent_tasks} for key: {task_name} and task: {task_id}"
)

return running_tasks_key, task_id
Expand Down

0 comments on commit 1764041

Please sign in to comment.