forbole / callisto

Callisto (formerly BDJuno) is the official Juno implementation for Big Dipper, the open-source block explorer for Cosmos
https://bigdipper.live
MIT License
91 stars 249 forks source link

[hasura actions]: How should we handle errors? #333

Closed ryuash closed 2 years ago

ryuash commented 2 years ago

Current Query:

  query Account($address: String!, $validatorAddress: String!) {
    commission: action_validator_commission_amount(address: $validatorAddress) {
      coins
    }
    withdrawalAddress: action_delegator_withdraw_address(address: $address) {
      address
    }
    accountBalances: action_account_balance(address: $address) {
      coins
    }
    delegationBalance: action_delegation_total(address: $address) {
      coins
    }
    unbondingBalance: action_unbonding_delegation_total(address: $address) {
      coins
    }
    delegationRewards: action_delegation_reward(address: $address) {
      validatorAddress: validator_address
      coins
    }
  }

If even one of these actions return an error the whole query will return an error.

For ex: In likecoin testnet: https://testnet.likecoin.bigdipper.live/accounts/cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn I'm getting the following error: error while getting delegator delegations: rpc error: code = NotFound desc = rpc error: code = NotFound desc = unable to find delegations for address cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn: key not found

Solution #1: If any of the actions return an error return their empty type.

Solution #2: The ui breaks up all actions in to its own query and error handles on the frontend

Let me know your thoughts

ryuash commented 2 years ago

Update: I went with solution 2 on my end. Getting trust issues with actions at the moment.

MonikaCat commented 2 years ago

Hey @ryuash this error is being thrown because DelegatorDelegations query returns an error instead of an empty object if the given address doesn't have any active delegations (coz of this line ) It was fixed in v.0.43.x so it only happens with chains that are still using stargate sdk. I will add a fix to stargate branch so we can better handle those exceptions on the backend

ryuash commented 2 years ago

Okay thanks ;)