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 8c666a0c0 fix(zentao): update error message when testing connection
fails (#7175) (#7176)
8c666a0c0 is described below
commit 8c666a0c02a1d86c2a21214b100a7aff812969cc
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Mar 15 12:07:09 2024 +0800
fix(zentao): update error message when testing connection fails (#7175)
(#7176)
Co-authored-by: Lynwee <[email protected]>
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),