From 6368ab1914d26f7b8f1900ee79e745d5097407d1 Mon Sep 17 00:00:00 2001 From: Minseong Choi Date: Thu, 2 Jul 2026 04:30:07 +0900 Subject: [PATCH] fix(api): coalesce MyServers owned flag so ownerless rows do not 500 The MyServers query lists both a user's own servers and unclaimed (owner_id IS NULL) servers, but computed owned as s.owner_id = $1. For an ownerless row that comparison is SQL NULL, which fails to scan into the Go bool and 500s the whole listing. Wrap it in COALESCE(..., false) so an ownerless row reports owned=false while still surfacing as claimable. --- internal/api/pgrepo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/api/pgrepo.go b/internal/api/pgrepo.go index 517af76..ca943b4 100644 --- a/internal/api/pgrepo.go +++ b/internal/api/pgrepo.go @@ -319,7 +319,7 @@ func (p *PGRepo) RecordJoin(ctx context.Context, name, mcUUID string) error { func (p *PGRepo) MyServers(ctx context.Context, userID string) ([]MyServerView, error) { const q = `SELECT s.name, COALESCE(sa.subdomain, ''), - (s.owner_id = $1) AS owned, (s.owner_id IS NULL) AS claimable, COALESCE(s.cached_phase, '') + COALESCE(s.owner_id = $1, false) AS owned, (s.owner_id IS NULL) AS claimable, COALESCE(s.cached_phase, '') FROM servers s LEFT JOIN server_aliases sa ON sa.server_name = s.name WHERE s.deleted_at IS NULL AND (s.owner_id = $1 OR s.owner_id IS NULL) ORDER BY s.name`