This is an automated email from the ASF dual-hosted git repository. lynwee pushed a commit to branch lw-0315 in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit f16da0ec0e923f97ec14cdf05523643e75978acd Author: houlinwei <[email protected]> AuthorDate: Fri Mar 15 11:35:19 2024 +0800 fix(zentao): update error message when testing connection fails --- 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),
