This is an automated email from the ASF dual-hosted git repository.
lynwee 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 1c3fc5357 fix: pr commit 404 (#7577)
1c3fc5357 is described below
commit 1c3fc5357fbdc7b6f10f5584c74baf8085b075ce
Author: abeizn <[email protected]>
AuthorDate: Thu Jun 6 15:00:27 2024 +0800
fix: pr commit 404 (#7577)
---
.../plugins/bitbucket_server/tasks/pr_commit_collector.go | 1 +
backend/plugins/bitbucket_server/tasks/task_data.go | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/backend/plugins/bitbucket_server/tasks/pr_commit_collector.go
b/backend/plugins/bitbucket_server/tasks/pr_commit_collector.go
index 1fd69f024..dabf58823 100644
--- a/backend/plugins/bitbucket_server/tasks/pr_commit_collector.go
+++ b/backend/plugins/bitbucket_server/tasks/pr_commit_collector.go
@@ -57,6 +57,7 @@ func CollectApiPullRequestCommits(taskCtx
plugin.SubTaskContext) errors.Error {
Input: iterator,
UrlTemplate: "rest/api/1.0/projects/{{
.Params.FullName }}/pull-requests/{{ .Input.BitbucketId }}/commits",
ResponseParser: GetRawMessageFromResponse,
+ AfterResponse: ignoreHTTPStatus404,
})
if err != nil {
return err
diff --git a/backend/plugins/bitbucket_server/tasks/task_data.go
b/backend/plugins/bitbucket_server/tasks/task_data.go
index 45d6c9858..dd2571e79 100644
--- a/backend/plugins/bitbucket_server/tasks/task_data.go
+++ b/backend/plugins/bitbucket_server/tasks/task_data.go
@@ -18,6 +18,8 @@ limitations under the License.
package tasks
import (
+ "net/http"
+
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/bitbucket_server/models"
@@ -77,3 +79,13 @@ func ValidateTaskOptions(op *BitbucketServerOptions)
errors.Error {
}
return 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 api.ErrIgnoreAndContinue
+ }
+ return nil
+}