Fix null volunteers array in shift instance JSON responses
All checks were successful
CI / Go tests & lint (push) Successful in 9s
CI / Frontend tests & type-check (push) Successful in 44s
CI / Go tests & lint (pull_request) Successful in 9s
CI / Frontend tests & type-check (pull_request) Successful in 44s

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 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 19:08:37 -03:00
parent 3900dff5a1
commit 0af53c9b55

View File

@@ -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