Skip to content
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

Address without delegations returns 500 #8902

Closed
4 tasks
lukitsbrian opened this issue Mar 17, 2021 · 3 comments · Fixed by #9015
Closed
4 tasks

Address without delegations returns 500 #8902

lukitsbrian opened this issue Mar 17, 2021 · 3 comments · Fixed by #9015
Assignees
Labels
C: gRPC Issues and PRs related to the gRPC service and HTTP gateway. T:Bug
Milestone

Comments

@lukitsbrian
Copy link

Summary of Bug

When querying the endpoint cosmos/staking/v1beta1/delegations/${address} it throws an error with code 500 if there are no delegations for the address, which leads to unnecessary error catching on client-side applications.

Rather, I would expect a response 200 with an empty array such as what is provided in the cosmos/staking/v1beta1/delegators/${address}/unbonding_delegations endpoint, or a 404.

Version

gaia 4.1.0
cosmos-sdk 0.42.1

Steps to Reproduce

# new address
gaiad keys add testing

# 200 response with empty array in response
curl -s -w "\nstatus: %{http_code}" https://cosmos.sg-1.online/cosmos/staking/v1beta1/delegators/$(gaiad keys show testing -a)/unbonding_delegations

# 500 response with error
curl -s -w "\nstatus: %{http_code}" https://cosmos.sg-1.online/cosmos/staking/v1beta1/delegations/$(gaiad keys show testing -a)


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@amaury1093 amaury1093 added T:Bug C: gRPC Issues and PRs related to the gRPC service and HTTP gateway. labels Mar 17, 2021
@alexanderbez
Copy link
Contributor

I'd opt for a 404 here. Was there a reason we chose 500 @AmauryM or is this a bug?

@amaury1093
Copy link
Contributor

amaury1093 commented Mar 17, 2021

In the gRPC handler, we return a NotFound error, which is imo 100% correct:

if delegations == nil {
return nil, status.Errorf(
codes.NotFound,
"unable to find delegations for address %s", req.DelegatorAddr)
}

My guess is this might be a gRPC-gateway error: codes.NotFound is translated into a 500 instead of a 404. @aleem1314 or @atheeshp do you know about this?

@atheeshp
Copy link
Contributor

I'm not sure, will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: gRPC Issues and PRs related to the gRPC service and HTTP gateway. T:Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants