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

klesh pushed a commit to branch kw-7000-jira-testconn-400
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit ad9aabadc24af5ac7abe7a0bfaef57b48023a3c3
Author: Klesh Wong <[email protected]>
AuthorDate: Tue Feb 27 15:17:17 2024 +0800

    Revert "fix: invalid url detection not working correctly (#7016)"
    
    This reverts commit 5ec63adb1f2fd894153a5ab8931a3bb8bb098dac.
---
 backend/plugins/jira/api/connection_api.go | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/backend/plugins/jira/api/connection_api.go 
b/backend/plugins/jira/api/connection_api.go
index 2a0fe3e32..aee973ef8 100644
--- a/backend/plugins/jira/api/connection_api.go
+++ b/backend/plugins/jira/api/connection_api.go
@@ -54,22 +54,22 @@ func testConnection(ctx context.Context, connection 
models.JiraConn) (*JiraTestC
        // serverInfo checking
        res, err := apiClient.Get("api/2/serverInfo", nil, nil)
        if err != nil {
-               // check if `/rest/` was missing
-               if strings.Contains(err.Error(), "status code 404") && 
!strings.HasSuffix(connection.Endpoint, "/rest/") {
-                       endpointUrl, err := url.Parse(connection.Endpoint)
-                       if err != nil {
-                               return nil, errors.Convert(err)
-                       }
-                       refUrl, err := url.Parse("/rest/")
-                       if err != nil {
-                               return nil, errors.Convert(err)
-                       }
-                       restUrl := endpointUrl.ResolveReference(refUrl)
-                       return nil, errors.NotFound.New(fmt.Sprintf("Seems like 
an invalid Endpoint URL, please try %s", restUrl.String()))
-               }
                return nil, err
        }
        serverInfoFail := "Failed testing the serverInfo: [ " + 
res.Request.URL.String() + " ]"
+       // check if `/rest/` was missing
+       if res.StatusCode == http.StatusNotFound && 
!strings.HasSuffix(connection.Endpoint, "/rest/") {
+               endpointUrl, err := url.Parse(connection.Endpoint)
+               if err != nil {
+                       return nil, errors.Convert(err)
+               }
+               refUrl, err := url.Parse("/rest/")
+               if err != nil {
+                       return nil, errors.Convert(err)
+               }
+               restUrl := endpointUrl.ResolveReference(refUrl)
+               return nil, errors.NotFound.New(fmt.Sprintf("Seems like an 
invalid Endpoint URL, please try %s", restUrl.String()))
+       }
        if res.StatusCode == http.StatusUnauthorized {
                return nil, errors.HttpStatus(http.StatusBadRequest).New("Error 
username/password")
        }

Reply via email to