Skip to content

Commit deea6a7

Browse files
authored
Merge pull request #5 from chkp-royl/master
Fix waitForTasks with empty array
2 parents edecb8b + 84004a4 commit deea6a7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

APIFiles/APIClient.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,10 @@ func (c *ApiClient) ApiCall(command string, payload map[string]interface{}, sid
363363
return APIResponse{}, err
364364
}
365365
} else if _, ok := res.data["tasks"]; ok {
366-
res = c.waitForTasks(res.data["tasks"].([]map[string]interface{}))
366+
tasks := res.data["tasks"].([]interface{})
367+
if len(tasks) > 0 {
368+
res = c.waitForTasks(tasks)
369+
}
367370
}
368371
}
369372
return res, nil
@@ -606,11 +609,11 @@ The version of waitForTask function for the collection of tasks
606609
task_objects: A list of task objects
607610
return: APIResponse object (response of show-task command).
608611
*/
609-
func (c *ApiClient) waitForTasks(taskObjects []map[string]interface{}) APIResponse {
612+
func (c *ApiClient) waitForTasks(taskObjects []interface{}) APIResponse {
610613

611614
var tasks []string
612615
for _, taskObj := range taskObjects {
613-
taskId := taskObj["task-id"]
616+
taskId := taskObj.(map[string]interface{})["task-id"]
614617
tasks = append(tasks, taskId.(string))
615618
c.waitForTask(taskId.(string))
616619
}

0 commit comments

Comments
 (0)