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

Return 400 http error for unknown account #912

Merged
merged 4 commits into from
Apr 4, 2023
Merged

Conversation

heifner
Copy link
Member

@heifner heifner commented Mar 28, 2023

See discussion on #903

Return a 400 http error code for unknown account instead of 500. 400 was chosen instead of 404 because 404 is seen by cleos as a plugin is not enabled. cleos could have been modified, but to better support existing cleos, went with the generic 400 error code.

The following endpoints were updated to return 400 when the account could not be accessed.
/v1/chain/get_abi
/v1/chain/get_code
/v1/chain/get_code_hash
/v1/chain/get_raw_code_and_abi
/v1/chain/get_raw_abi
/v1/chain/get_account
/v1/chain/get_table_rows
/v1/chain/get_currency_balance
/v1/chain/get_currency_stats

./cleos --print-response get account test
RESPONSE:
---------------------
{
  "code": 400,
  "message": "Account lookup",
  "error": {
    "code": 3060002,
    "name": "account_query_exception",
    "what": "Account Query Exception",
    "details": [{
        "message": "unable to retrieve account info (unknown key (boost::tuples::tuple<bool, eosio::chain::name, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>): (0 test))",
        "file": "chain_plugin.cpp",
        "line_number": 2555,
        "method": "get_account"
      }
    ]
  }
}
---------------------
Error 3060002: Account Query Exception
Most likely, the given account doesn't exist in the blockchain.
Error Details:
unable to retrieve account info (unknown key (boost::tuples::tuple<bool, eosio::chain::name, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>): (0 test))

Resolves #591

@heifner heifner added documentation Improvements or additions to documentation OCI Work exclusive to OCI team labels Mar 28, 2023
@@ -2339,9 +2344,11 @@ read_only::get_code_hash_results read_only::get_code_hash( const get_code_hash_p
result.code_hash = accnt.code_hash;

return result;
} EOS_RETHROW_EXCEPTIONS(chain::account_query_exception, "unable to retrieve account code has")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/has/hash/

@heifner heifner requested a review from spoonincode March 31, 2023 12:25
Copy link
Member

@spoonincode spoonincode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most limited change so far, and it's going in to main. But it still is changing the response code & body for extremely widely used endpoints that have behaved the way they do since 1.0; without performing any sort of versioning of the API. Pretty scary feeling to me. I guess we'll have ample time to communicate the change somehow before 5.0.

@heifner heifner merged commit 50a4728 into main Apr 4, 2023
@heifner heifner deleted the GH-591-get-account-http branch April 4, 2023 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation OCI Work exclusive to OCI team
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Fix get_account fail case, RPC endpoint for is_valid_account
3 participants