-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace all REST query empty result HTTP Status codes to 200 #4065
Changes from 2 commits
549a1d5
b501a2c
5f32f04
18a65fc
c23b54a
32df57f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ func QueryAccountRequestHandlerFn( | |
|
||
// the query will return empty if there is no data for this account | ||
if len(res) == 0 { | ||
w.WriteHeader(http.StatusNoContent) | ||
w.WriteHeader(http.StatusOK) | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
} | ||
|
||
|
@@ -88,7 +88,7 @@ func QueryBalancesRequestHandlerFn( | |
|
||
// the query will return empty if there is no data for this account | ||
if len(res) == 0 { | ||
w.WriteHeader(http.StatusNoContent) | ||
w.WriteHeader(http.StatusOK) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious if this function is a duplicate from the one above ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of it is duplicated, only change is response. Eg. for The balance endpoint does not make sense for me, it should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree it doesn’t make much sense. Let’s open an issue for it |
||
return | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,7 +310,7 @@ func queryDepositHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.Han | |
|
||
if len(strProposalID) == 0 { | ||
err := errors.New("proposalId required but not specified") | ||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rest.WriteErrorResponse(w, http.StatusOK, err.Error()) | ||
return | ||
} | ||
|
||
|
@@ -321,7 +321,7 @@ func queryDepositHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.Han | |
|
||
if len(bechDepositorAddr) == 0 { | ||
err := errors.New("depositor address required but not specified") | ||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rest.WriteErrorResponse(w, http.StatusOK, err.Error()) | ||
return | ||
} | ||
|
||
|
@@ -387,7 +387,7 @@ func queryVoteHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.Handle | |
|
||
if len(strProposalID) == 0 { | ||
err := errors.New("proposalId required but not specified") | ||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rest.WriteErrorResponse(w, http.StatusOK, err.Error()) | ||
return | ||
} | ||
|
||
|
@@ -398,7 +398,7 @@ func queryVoteHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.Handle | |
|
||
if len(bechVoterAddr) == 0 { | ||
err := errors.New("voter address required but not specified") | ||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rest.WriteErrorResponse(w, http.StatusOK, err.Error()) | ||
return | ||
} | ||
|
||
|
@@ -464,7 +464,7 @@ func queryVotesOnProposalHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) | |
|
||
if len(strProposalID) == 0 { | ||
err := errors.New("proposalId required but not specified") | ||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rest.WriteErrorResponse(w, http.StatusOK, err.Error()) | ||
return | ||
} | ||
|
||
|
@@ -579,7 +579,7 @@ func queryTallyOnProposalHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) | |
|
||
if len(strProposalID) == 0 { | ||
err := errors.New("proposalId required but not specified") | ||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. noted. Reverted. |
||
rest.WriteErrorResponse(w, http.StatusOK, err.Error()) | ||
return | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,11 +48,6 @@ func signingInfoHandlerFn(cliCtx context.CLIContext, storeName string, cdc *code | |
return | ||
} | ||
|
||
if code == http.StatusNoContent { | ||
w.WriteHeader(http.StatusNoContent) | ||
return | ||
} | ||
|
||
rest.PostProcessResponse(w, cdc, signingInfo, cliCtx.Indent) | ||
} | ||
} | ||
|
@@ -64,7 +59,7 @@ func signingInfoHandlerListFn(cliCtx context.CLIContext, storeName string, cdc * | |
|
||
_, page, limit, err := rest.ParseHTTPArgs(r) | ||
if err != nil { | ||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is also correct and shouldn't be removed, since this checks for badly parsed query parameters There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted. Reverted |
||
rest.WriteErrorResponse(w, http.StatusOK, err.Error()) | ||
return | ||
} | ||
|
||
|
@@ -81,7 +76,7 @@ func signingInfoHandlerListFn(cliCtx context.CLIContext, storeName string, cdc * | |
} | ||
|
||
if len(validators.Validators) == 0 { | ||
w.WriteHeader(http.StatusNoContent) | ||
w.WriteHeader(http.StatusOK) | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
} | ||
|
||
|
@@ -100,7 +95,7 @@ func signingInfoHandlerListFn(cliCtx context.CLIContext, storeName string, cdc * | |
} | ||
|
||
if len(signingInfoList) == 0 { | ||
w.WriteHeader(http.StatusNoContent) | ||
w.WriteHeader(http.StatusOK) | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
} | ||
|
||
|
@@ -132,7 +127,7 @@ func getSigningInfo(cliCtx context.CLIContext, storeName string, cdc *codec.Code | |
} | ||
|
||
if len(res) == 0 { | ||
code = http.StatusNoContent | ||
code = http.StatusOK | ||
return | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add check for empty account (eg.
Account{}
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a test
TestAccountBalanceQuery
which covers checking if we are returning empty Account{}