Skip to content

fix: Return 404 for missing tables in get_table_count API#1393

Draft
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/warehouse-table-not-found-404
Draft

fix: Return 404 for missing tables in get_table_count API#1393
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/warehouse-table-not-found-404

Conversation

@sentry

@sentry sentry Bot commented May 29, 2026

Copy link
Copy Markdown

This PR addresses issue DALGO-BACKEND-2H1 by changing the behavior of the /api/warehouse/table_count/{schema_name}/{table_name} endpoint when a requested table does not exist.

Problem: Previously, if a client requested the row count for a table that did not exist in the warehouse (e.g., intermediate.int_2digit), the underlying database (PostgreSQL or BigQuery) would raise an error like "relation does not exist". This error was caught by a generic exception handler in the API, resulting in an HTTP 500 Internal Server Error.

Solution:

  1. Introduced a new custom exception TableNotFoundError in ddpui/utils/warehouse/exceptions.py.
  2. Modified get_total_rows methods in both ddpui/utils/warehouse/old_client/postgres.py and ddpui/utils/warehouse/old_client/bigquery.py to specifically catch database-specific "table not found" errors (psycopg2.errors.UndefinedTable for Postgres and google.cloud.exceptions.NotFound for BigQuery).
  3. These specific exceptions are now re-raised as the common TableNotFoundError.
  4. The get_table_count endpoint in ddpui/api/warehouse_api.py was updated to catch TableNotFoundError and return an HttpError(404, "Table not found").

Impact: This change provides a more semantically correct and user-friendly response (HTTP 404 Not Found) when a requested table is unavailable, improving API robustness and client-side error handling.

Fixes DALGO-BACKEND-2H1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants