From 0af53c9b55be90ecb41c07f345ac68745954a7bf Mon Sep 17 00:00:00 2001 From: James Griffin Date: Wed, 8 Apr 2026 19:08:37 -0300 Subject: [PATCH] Fix null volunteers array in shift instance JSON responses Initialize slice helpers with make() instead of var declaration so empty results serialize as [] instead of null in JSON, fixing the frontend TypeError on the schedules page. Co-Authored-By: Claude Opus 4.6 --- internal/schedule/schedule.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/schedule/schedule.go b/internal/schedule/schedule.go index eba2e0b..ff8ae07 100644 --- a/internal/schedule/schedule.go +++ b/internal/schedule/schedule.go @@ -590,7 +590,7 @@ func (s *Store) templateRoles(ctx context.Context, templateID int64) ([]Template return nil, fmt.Errorf("get template roles: %w", err) } defer rows.Close() - var roles []TemplateRole + roles := make([]TemplateRole, 0) for rows.Next() { var r TemplateRole if err := rows.Scan(&r.ID, &r.TemplateID, &r.RoleName, &r.Count); err != nil { @@ -608,7 +608,7 @@ func (s *Store) templateVolunteerIDs(ctx context.Context, templateID int64) ([]i return nil, fmt.Errorf("get template volunteers: %w", err) } defer rows.Close() - var ids []int64 + ids := make([]int64, 0) for rows.Next() { var id int64 if err := rows.Scan(&id); err != nil { @@ -631,7 +631,7 @@ func (s *Store) instanceVolunteers(ctx context.Context, instanceID int64) ([]Ins return nil, fmt.Errorf("get instance volunteers: %w", err) } defer rows.Close() - var vols []InstanceVolunteer + vols := make([]InstanceVolunteer, 0) for rows.Next() { var iv InstanceVolunteer var confirmedAt sql.NullString