Files
Jordi Enric 833a875ea2 fix(studio): friendly database metric errors DEBUG-155 (#52216)
## Problem

The Database section of Observability displays raw infrastructure API
errors in metric cards, making failures confusing and repetitive.

## Fix

Show one friendly alert with refresh, support, and service-status
guidance when the infrastructure request fails. Keep Slow Queries
visible, and show “Unable to load” only on affected cards for partial
failures while preserving healthy metrics.

The Overview Refresh button now invalidates the active project’s
connection-limit query. Previously it used a cache key that matched no
active query, so Peak Connections could stay on “Unable to load” while
the other cards refreshed.

Consolidates and supersedes #47491 and #47495, adapted to the current
batched metrics implementation.

## How to test

- Open Observability and verify that successful database metrics still
render.
- Simulate a failed infrastructure request. Expect one friendly alert,
no raw backend message, and Slow Queries still visible.
- Simulate an individual metric or connection-limit failure. Expect only
the affected card to show “Unable to load”.

- With the connection-limit request failing, click **Refresh** and
confirm that Peak Connections shows “Unable to load”. Restore the
response and click **Refresh** again. The card should show the peak and
limit without a browser reload.

## QA results

- **Hosted Refresh recovery passed on `ee646999af`.** After the
connection-limit request recovered, one click sent a new request and
replaced “Unable to load” with `6/90`. The other five hosted cases
passed on `dbf78487f5`. [Automated QA
review](https://github.com/supabase/supabase/pull/52216#pullrequestreview-6169329677)
- **Local Chromium recovery passed on the same commit.** With a
simulated HTTP 500 followed by success, Refresh retried the query and
displayed `12/100`. CPU, Memory, and Disk remained healthy.
- All 52 focused tests passed with retries disabled and shuffled order.
The recovery test failed with the original Refresh handler. Studio
typecheck passed. GitHub reported 38 successful checks and six skipped
checks.

Fixes
https://linear.app/supabase/issue/DEBUG-155/frontend-should-render-nice-error-message-on-infra-monitoring-api

## QA screenshots

### Peak Connections before and after the Refresh fix

**Before · `dbf78487f5`.** Peak Connections still showed “Unable to
load” after two Refresh clicks, even as the other metrics reloaded.

![Peak Connections stuck on Unable to load after
Refresh](https://k6dwnfm8zepsmdni.public.blob.vercel-storage.com/qa/wrun_41M8XTANCW0GQ8139AY6ECPK81/1796297469653-screenshot-1796297456016.png)

**After · `ee646999af`.** Once the connection-limit request could
succeed, the next Refresh click restored Peak Connections to `6/90`.

![Peak Connections showing 6/90 after in-app
Refresh](https://k6dwnfm8zepsmdni.public.blob.vercel-storage.com/qa/wrun_41M8XTANCW0GQ8139AY6ECPK81/1796299167534-screenshot-1796299160944.png)

### Local browser with HTTP overrides

Actual PR component at `dbf78487f5`, rendered in a local fixture harness
at a 1440 × 900 viewport. Playwright intercepted the infrastructure API
request; these are local simulated error states, not hosted-preview
captures.

**Full request failure:** one friendly alert; raw backend details are
hidden and Slow Queries remains visible.

![Full request failure — local HTTP
override](https://github.com/user-attachments/assets/f9b85b1d-f836-47ce-ad48-bab13e558079)

**Partial failure:** only Disk IO Budget shows “Unable to load”; healthy
metrics and Slow Queries remain visible.

![Partial metric failure — local HTTP
override](https://github.com/user-attachments/assets/f7dbc088-d505-4f20-8a55-45d832b828a8)

**Recovery:** after restoring a successful response and reloading, all
metric cards render normally.

![Healthy recovery — local HTTP
override](https://github.com/user-attachments/assets/34d3332e-717b-47ff-ba56-e00128fa474c)

### Verified hosted preview

Studio staging deployment for `dbf78487f5`, 1440 × 900. All database
metric cards and Slow Queries return after Refresh.

![Overview after
Refresh](https://github.com/user-attachments/assets/67304cac-3dfd-4afe-b717-0a1fa12a30ba)

The CPU card opens the Database report and preserves Last 24 hours.

![Database report opened from a metric
card](https://github.com/user-attachments/assets/c70eb7c8-4151-4080-ba6c-69efb675d7ab)
2026-12-03 14:03:33 +01:00
..