bug: Dashboard crashes with 'Koneksi bermasalah' when kanban_board_view is missing

Resolved 💬 2 comments Opened Mar 25, 2026 by gerynugrh Closed Mar 28, 2026

Bug

The dashboard page (/b/{businessId}/dashboard/{boardId}) crashes with a generic "Koneksi bermasalah" error when the kanban_board_view table has zero rows for the given board_id.

Root Cause

In apps/web/src/routes/b/$businessId/dashboard/$dashboardId.tsx (line 97-101):

const { data: view, error: viewError } = await supabase
  .from("kanban_board_view")
  .select("*")
  .eq("board_id", board.id)
  .single();

The .single() call throws "Cannot coerce the result to a single JSON object" when:

  • Zero rows exist (new business with a dashboard board but no view created yet)
  • Multiple rows exist (duplicate views for the same board)

This causes a 500 error that surfaces as "Koneksi bermasalah" to the user.

Expected Behavior

  • If no view exists, the dashboard should either create a default view or show an empty state/setup wizard.
  • If multiple views exist, it should pick the most recent one (e.g., .order("created_at", { ascending: false }).limit(1).single()).

Reproduction

  1. Create a new business with a custom-top-level-dashboard kanban board
  2. Do NOT create a kanban_board_view row for it
  3. Navigate to /b/{localId}/dashboard/{boardId}
  4. Observe: 500 error → "Koneksi bermasalah"

Suggested Fix

Replace .single() with .maybeSingle() and handle the null case gracefully — either auto-create a default view or render an empty dashboard state.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗