You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2024/03/05 09:29:37 UTC

(incubator-devlake) branch release-v0.21 updated: fix: sonarqube test connection can not effective (#7112) (#7113)

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

abeizn pushed a commit to branch release-v0.21
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.21 by this push:
     new 58128d80c fix: sonarqube test connection can not effective (#7112) (#7113)
58128d80c is described below

commit 58128d80c636f2b63a57597eca4311ed01fbe4de
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Tue Mar 5 17:29:33 2024 +0800

    fix: sonarqube test connection can not effective (#7112) (#7113)
    
    * fix: sonarqube test connection can not effective
    
    * fix: testConnection add check
    
    Co-authored-by: abeizn <zi...@merico.dev>
---
 backend/plugins/sonarqube/api/connection_api.go | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/backend/plugins/sonarqube/api/connection_api.go b/backend/plugins/sonarqube/api/connection_api.go
index 29f26370c..9058ce3f7 100644
--- a/backend/plugins/sonarqube/api/connection_api.go
+++ b/backend/plugins/sonarqube/api/connection_api.go
@@ -19,6 +19,7 @@ package api
 
 import (
 	"context"
+	"fmt"
 	"net/http"
 
 	"github.com/apache/incubator-devlake/core/errors"
@@ -95,6 +96,10 @@ func TestConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput,
 	if testConnectionErr != nil {
 		return nil, plugin.WrapTestConnectionErrResp(basicRes, testConnectionErr)
 	}
+	if testConnectionResult.Status != http.StatusOK {
+		errMsg := fmt.Sprintf("Test connection fail, unexpected status code: %d", testConnectionResult.Status)
+		return nil, plugin.WrapTestConnectionErrResp(basicRes, errors.Default.New(errMsg))
+	}
 	return &plugin.ApiResourceOutput{Body: testConnectionResult, Status: http.StatusOK}, nil
 }
 
@@ -116,6 +121,10 @@ func TestExistingConnection(input *plugin.ApiResourceInput) (*plugin.ApiResource
 	if testConnectionErr != nil {
 		return nil, plugin.WrapTestConnectionErrResp(basicRes, testConnectionErr)
 	}
+	if testConnectionResult.Status != http.StatusOK {
+		errMsg := fmt.Sprintf("Test connection fail, unexpected status code: %d", testConnectionResult.Status)
+		return nil, plugin.WrapTestConnectionErrResp(basicRes, errors.Default.New(errMsg))
+	}
 	return &plugin.ApiResourceOutput{Body: testConnectionResult, Status: http.StatusOK}, nil
 }