Skip to content

Commit

Permalink
Merge pull request #87 from milobella/fix/nil-slices-ability
Browse files Browse the repository at this point in the history
fix: init of ability slices
  • Loading branch information
celian-garcia authored Oct 16, 2022
2 parents 1323ae5 + 0d8e977 commit f68380d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/ability/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ func (s *serviceImpl) RequestAbility(nlu cerebro.NLU, ctx ability.Context, devic

// GetCacheAbilities fetch the abilities from the cache.
func (s *serviceImpl) GetCacheAbilities() ([]*model.Ability, error) {
cacheItems := s.clientsCache.Items()
abilities := make([]*model.Ability, len(cacheItems))
for intent, item := range cacheItems {
abilities := make([]*model.Ability, 0)
for intent, item := range s.clientsCache.Items() {
client, ok := item.Object.(*ability.Client)
if !ok {
return nil, fmt.Errorf("error casting cache entry into %T", &ability.Client{})
Expand All @@ -130,7 +129,7 @@ func (s *serviceImpl) GetDatabaseAbilities() ([]*model.Ability, error) {

// GetConfigAbilities fetch the abilities from the configuration.
func (s *serviceImpl) GetConfigAbilities() ([]*model.Ability, error) {
abilities := make([]*model.Ability, len(s.clientsFromConfig))
abilities := make([]*model.Ability, 0)
for intent, client := range s.clientsFromConfig {
abilities = append(abilities, &model.Ability{
Name: client.Name,
Expand Down

0 comments on commit f68380d

Please sign in to comment.