Skip to content

Commit

Permalink
MUL-1794: /account/get_by_key zero-length string array on empty response
Browse files Browse the repository at this point in the history
  • Loading branch information
vovapi committed Aug 1, 2018
1 parent e43d96b commit cf14c80
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions client/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -2494,6 +2494,7 @@ func (server *RestClient) accountGetByKey(ctx *gin.Context) {
})
return
}

if key.PublicKey == "" {
ctx.JSON(http.StatusBadRequest, gin.H{
"code": http.StatusBadRequest,
Expand All @@ -2510,6 +2511,19 @@ func (server *RestClient) accountGetByKey(ctx *gin.Context) {
})
return
}
if accounts == nil {
server.log.Errorf("eos get_key_accounts: %s", err)
ctx.JSON(http.StatusInternalServerError, gin.H{
"code": http.StatusInternalServerError,
"message": http.StatusText(http.StatusInternalServerError),
})
return
}

if accounts.AccountNames == nil {
accounts.AccountNames = make([]string, 0)
}

ctx.JSON(http.StatusOK, gin.H{
"code": http.StatusOK,
"account_names": accounts.AccountNames,
Expand Down

0 comments on commit cf14c80

Please sign in to comment.