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.2] Modify trace_api_plugin to report serialization errors to user #1449

Merged
merged 7 commits into from
Jul 28, 2023

Conversation

heifner
Copy link
Member

@heifner heifner commented Jul 25, 2023

The exception handler for the trace_api_plugin data handler now rethrows any exceptions so they can be reported to the API caller of /v1/trace_api/get_block and /v1/trace_api/get_transaction_trace.

trace_api_plugin will now report

./cleos --verbose --print-response get block_trace 20
RESPONSE:
---------------------
{
  "code": 500,
  "message": "Internal Service Error",
  "error": {
    "code": 2,
    "name": "timeout_exception",
    "what": "deadline 2023-07-25T20:19:49.442 exceeded by 24us ",
    "details": [{
        "message": "deadline 2023-07-25T20:19:49.442 exceeded by 24us ",
        "file": "trace_api_plugin.cpp",
        "line_number": 288,
        "method": "operator()"
      }
    ]
  }
}
---------------------
error 2023-07-25T20:19:49.445 cleos     main.cpp:4498                 operator()           ] Failed with error: 2 timeout_exception: deadline 2023-07-25T20:19:49.442 exceeded by 24us
deadline 2023-07-25T20:19:49.442 exceeded by 24us
    {}
    cleos  trace_api_plugin.cpp:288 operator()

Instead of:

./cleos --verbose --print-response get block_trace 20
RESPONSE:
---------------------
{
  "code": 404,
  "message": "Trace API: block trace missing",
  "error": {
    "code": 0,
    "name": "",
    "what": "",
    "details": []
  }
}
---------------------
Error 3200005: http request fail
Error Details:
Error code 404
: {"code":404,"message":"Trace API: block trace missing","error":{"code":0,"name":"","what":"","details":[]}}

Resolves #1433

@heifner heifner added the OCI Work exclusive to OCI team label Jul 25, 2023
BOOST_CHECK_EXCEPTION(handler.serialize_to_variant(action_trace_t, [&](){ ++depth; if (depth > 1) throw std::runtime_error("oops"); }), std::runtime_error,
[](const std::runtime_error& e) {
return std::string(e.what()).find("oops") != std::string::npos;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably you should either check except_called == true here, or remove the variable alltogether.

Copy link
Contributor

Choose a reason for hiding this comment

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

PS: cool test. Did you make up the abi out of thin air?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I meant to add a check for that. Added.
It was copied from another test. Originally hand-crafted.

Comment on lines +112 to +113
cmd=" --print-response %s %d" % (cmdDesc, blockNum)
cmd="%s %s %s" % (Utils.EosClientPath, node.eosClientArgs(), cmd)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do it in 2 steps, and not:
cmd="%s %s --print-response %s %d" % (Utils.EosClientPath, node.eosClientArgs(), cmdDesc, blockNum)

Copy link
Member Author

Choose a reason for hiding this comment

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

No reason except that it was copied from another location that builds it up similar.

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.

trace_api_plugin reports block trace missing when http-max-response-time-ms limit is reached
3 participants