fix(api): return empty arrays not null for empty lists (frontend null.length crash)
Root cause: store List* methods used 'var out []T' which stays nil on empty
result sets and serializes to JSON null; the SPA then crashed on .length/.map
(e.g. endpoints.length on the Tasks page right after deploy). Return []T{}
at the source; coerce null->[] on the frontend load sites as defense-in-depth.
Regression test asserts List* are non-nil when empty.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMHQTtnQtQqL8muAXHr9kd
This commit is contained in:
@@ -34,7 +34,7 @@ func (s *Store) ListEndpoints(ctx context.Context) ([]Endpoint, error) {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var out []Endpoint
|
||||
out := []Endpoint{}
|
||||
for rows.Next() {
|
||||
var e Endpoint
|
||||
if err := rows.Scan(&e.ID, &e.RoleLabel, &e.Host, &e.Port, &e.TLSMode); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user