This is an automated email from the ASF dual-hosted git repository.
abeizn 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 9833fd750 fix(zentao): update error message when testing connection
fails (#7175)
9833fd750 is described below
commit 9833fd75075e5352d68f9f5b6f5017ba76330b42
Author: Lynwee <[email protected]>
AuthorDate: Fri Mar 15 12:04:07 2024 +0800
fix(zentao): update error message when testing connection fails (#7175)
Co-authored-by: houlinwei <[email protected]>
---
backend/plugins/zentao/models/access_token.go | 1 +
backend/plugins/zentao/models/connection.go | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/backend/plugins/zentao/models/access_token.go
b/backend/plugins/zentao/models/access_token.go
index 60bf26178..d084348fb 100644
--- a/backend/plugins/zentao/models/access_token.go
+++ b/backend/plugins/zentao/models/access_token.go
@@ -24,4 +24,5 @@ type ApiAccessTokenRequest struct {
type ApiAccessTokenResponse struct {
Token string `json:"token"`
+ Error string `json:"error"`
}
diff --git a/backend/plugins/zentao/models/connection.go
b/backend/plugins/zentao/models/connection.go
index ccce2010e..0554450e7 100644
--- a/backend/plugins/zentao/models/connection.go
+++ b/backend/plugins/zentao/models/connection.go
@@ -50,7 +50,11 @@ func (connection ZentaoConn) PrepareApiClient(apiClient
plugin.ApiClient) errors
return errors.HttpStatus(http.StatusBadRequest).Wrap(err,
"failed UnmarshalResponse for tokenResBody")
}
if tokenResBody.Token == "" {
- return errors.HttpStatus(http.StatusBadRequest).New("failed to
request access token")
+ msg := "failed to request access token"
+ if tokenResBody.Error != "" {
+ msg = tokenResBody.Error
+ }
+ return errors.HttpStatus(http.StatusBadRequest).New(msg)
}
apiClient.SetHeaders(map[string]string{
"Token": fmt.Sprintf("%v", tokenResBody.Token),