Skip to content

Commit 8236d4f

Browse files
committed
feat(spctl): Search props fix
1 parent aec91df commit 8236d4f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmd/spctl/search.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"fmt"
5+
46
"github.com/AlecAivazis/survey/v2"
57
"github.com/koltyakov/gosip/api"
68
)
@@ -68,8 +70,14 @@ func getSearchConf(sp *api.SP) (SearchConf, error) {
6870
return searchConf, err
6971
}
7072

73+
rows := res.Data().PrimaryQueryResult.RelevantResults.Table.Rows
74+
if len(rows) == 0 {
75+
fmt.Println("Warning: no results found for the query")
76+
return searchConf, nil
77+
}
78+
7179
searchProps := []string{}
72-
for _, prop := range res.Data().PrimaryQueryResult.RelevantResults.Table.Rows[0].Cells {
80+
for _, prop := range rows[0].Cells {
7381
propName := prop.Key
7482
searchProps = append(searchProps, propName)
7583
}

0 commit comments

Comments
 (0)