Skip to content

Commit

Permalink
relay: return explicit empty array, not nil, for sync.listRepos
Browse files Browse the repository at this point in the history
  • Loading branch information
bnewbold committed Dec 13, 2023
1 parent 25a236f commit f12bac3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bgs/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ func (s *BGS) handleComAtprotoSyncListRepos(ctx context.Context, cursor string,
}
}

resp := &comatprototypes.SyncListRepos_Output{
Repos: []*comatprototypes.SyncListRepos_Repo{},
}

users := []User{}
if err := s.db.Model(&User{}).Where("id > ? AND NOT tombstoned AND NOT taken_down", c).Order("id").Limit(limit).Find(&users).Error; err != nil {
if err == gorm.ErrRecordNotFound {
Expand All @@ -212,11 +216,8 @@ func (s *BGS) handleComAtprotoSyncListRepos(ctx context.Context, cursor string,
}

if len(users) == 0 {
return &comatprototypes.SyncListRepos_Output{}, nil
}

resp := &comatprototypes.SyncListRepos_Output{
Repos: []*comatprototypes.SyncListRepos_Repo{},
// resp.Repos is an explicit empty array, not just 'nil'
return resp, nil
}

for i := range users {
Expand Down

0 comments on commit f12bac3

Please sign in to comment.