This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new a3c46a2c fix: github job collector occurs 404 (#3178)
a3c46a2c is described below

commit a3c46a2cf3898614cb37159623c56b3449883050
Author: abeizn <[email protected]>
AuthorDate: Mon Sep 26 11:49:38 2022 +0800

    fix: github job collector occurs 404 (#3178)
---
 plugins/github/tasks/cicd_job_collector.go |  4 +++-
 plugins/github/tasks/shared.go             | 13 ++++++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/plugins/github/tasks/cicd_job_collector.go 
b/plugins/github/tasks/cicd_job_collector.go
index aa17b170..9ec0c87e 100644
--- a/plugins/github/tasks/cicd_job_collector.go
+++ b/plugins/github/tasks/cicd_job_collector.go
@@ -20,11 +20,12 @@ package tasks
 import (
        "encoding/json"
        "fmt"
-       "github.com/apache/incubator-devlake/errors"
        "net/http"
        "net/url"
        "reflect"
 
+       "github.com/apache/incubator-devlake/errors"
+
        "github.com/apache/incubator-devlake/plugins/core"
        "github.com/apache/incubator-devlake/plugins/core/dal"
        "github.com/apache/incubator-devlake/plugins/github/models"
@@ -87,6 +88,7 @@ func CollectJobs(taskCtx core.SubTaskContext) errors.Error {
                        }
                        return body.GithubWorkflowJobs, nil
                },
+               AfterResponse: ignoreHTTPStatus404,
        })
 
        if err != nil {
diff --git a/plugins/github/tasks/shared.go b/plugins/github/tasks/shared.go
index 65c08711..9f3fdd83 100644
--- a/plugins/github/tasks/shared.go
+++ b/plugins/github/tasks/shared.go
@@ -18,9 +18,10 @@ limitations under the License.
 package tasks
 
 import (
+       "net/http"
+
        "github.com/apache/incubator-devlake/errors"
        "github.com/apache/incubator-devlake/plugins/github/utils"
-       "net/http"
 
        "github.com/apache/incubator-devlake/plugins/helper"
 )
@@ -33,3 +34,13 @@ func GetTotalPagesFromResponse(res *http.Response, args 
*helper.ApiCollectorArgs
        }
        return pageInfo.Last, nil
 }
+
+func ignoreHTTPStatus404(res *http.Response) errors.Error {
+       if res.StatusCode == http.StatusUnauthorized {
+               return errors.Unauthorized.New("authentication failed, please 
check your AccessToken")
+       }
+       if res.StatusCode == http.StatusNotFound {
+               return helper.ErrIgnoreAndContinue
+       }
+       return nil
+}

Reply via email to