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

[3.1] Report account not found instead of boost unknown key error #188

Closed
wants to merge 1 commit into from

Conversation

heifner
Copy link
Member

@heifner heifner commented Sep 19, 2022

/v1/chain/get_account was reporting a boost unknown key. Change error to account_query_exception to provide a better error message when an account does not exist.

Before:

$ ./cleos get account kevinheifner
error 2022-09-19T13:50:59.159 cleos     main.cpp:4121                 operator()           ] Failed with error: unspecified (0)
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 kevinheifner)
$ ./cleos --print-response get account kevinheifner
RESPONSE:
---------------------
{
  "code": 500,
  "message": "Internal Service Error",
  "error": {
    "code": 0,
    "name": "exception",
    "what": "unspecified",
    "details": [{
        "message": "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 kevinheifner)",
        "file": "http_plugin.cpp",
        "line_number": 516,
        "method": "handle_exception"
      }
    ]
  }
}
---------------------

After:

$ ./cleos get account kevinheifner
Error 3060002: Account Query Exception
Most likely, the given account doesn't exist in the blockchain.
Error Details:
Account not found: kevinheifner
$ ./cleos --print-response get account kevinheifner
RESPONSE:
---------------------
{
  "code": 500,
  "message": "Internal Service Error",
  "error": {
    "code": 3060002,
    "name": "account_query_exception",
    "what": "Account Query Exception",
    "details": [{
        "message": "Account not found: kevinheifner",
        "file": "chain_plugin.cpp",
        "line_number": 2430,
        "method": "get_account"
      }
    ]
  }
}
---------------------

On the server now:

debug 2022-09-19T15:14:17.623 nodeos    http_plugin.cpp:952           handle_exception     ] Exception while processing chain.get_account: 3060002 account_query_exception: Account Query Exception
Account not found: kevinheifner
    {"a":"kevinheifner"}
    nodeos  chain_plugin.cpp:2430 get_account
account: kevinheifner
    {"a":"kevinheifner"}
    nodeos  chain_plugin.cpp:2590 get_account

Guarded by debug level output.

Resolves #186

@heifner heifner added the OCI Work exclusive to OCI team label Sep 19, 2022
@spoonincode
Copy link
Member

Is changing the error code and message for a response like this considering breaking? Is it possible someone is parsing the response for certain messages and this would change behavior?

@heifner
Copy link
Member Author

heifner commented Sep 19, 2022

Is changing the error code and message for a response like this considering breaking? Is it possible someone is parsing the response for certain messages and this would change behavior?

Maybe. @arhag ? If so, I can move this to 3.2.

@heifner
Copy link
Member Author

heifner commented Sep 20, 2022

Decided this was too much of a breaking change outside at least a 4.0 release as the error code and error message is modified by this change. It is possible and maybe likely that users are expecting the current error code and/or error string when the account does not exist. Closing with the plan that this along with other enhancements for the HTTP API will be made in future releases likely in a different namespace such as /v3/chain/get_account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants