瀏覽代碼

fix nil pointer error in GetLatestWorkflowRun

Mohammed Nafees 4 年之前
父節點
當前提交
9d8fc74f53
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      api/server/shared/commonutils/git_utils.go

+ 2 - 2
api/server/shared/commonutils/git_utils.go

@@ -22,7 +22,7 @@ func GetLatestWorkflowRun(client *github.Client, owner, repo, filename, branch s
 		},
 	)
 
-	if ghResponse.StatusCode == http.StatusNotFound {
+	if ghResponse != nil && ghResponse.StatusCode == http.StatusNotFound {
 		return nil, ErrWorkflowNotFound
 	}
 
@@ -30,7 +30,7 @@ func GetLatestWorkflowRun(client *github.Client, owner, repo, filename, branch s
 		return nil, err
 	}
 
-	if workflowRuns.GetTotalCount() == 0 {
+	if workflowRuns == nil || workflowRuns.GetTotalCount() == 0 {
 		return nil, ErrNoWorkflowRuns
 	}