RFC: Web API error response_metadata is buried
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reading lib/slack/web/faraday/response/raise_error.rb, where the response error becomes the SlackError message, and inspect how response.body is exposed. The issue proposes several possible API and configuration changes, so first confirm the desired behavior with maintainers; done would require an agreed design and corresponding coverage for verbose messages and response attributes.
Written by the indexing model from the issue text.
Description
In some of the more recent Web API methods the most relevant error information is given in the response_metadata. For instance here's an example of Slack's response body for a bad call to views.open:
{
"ok": false,
"error": "invalid_arguments",
"response_metadata": {
"messages": [
"[ERROR] missing required field: title [json-pointer:/view]",
"[ERROR] missing required field: blocks [json-pointer:/view]",
"[ERROR] missing required field: type [json-pointer:/view]"
]
}
}
The error value of invalid_arguments is basically useless on its own — it's necessary to look at the response_metadata to understand the problem with the request.
Currently this library pulls out the error value and uses this for the message on SlackError (here). It's possible to access the reseponse_metadata with slack_error.response.body.response_metadata. However my problem is that when an error is raised my logs only show the error, because that is the message (and as far as I can tell, raise prints Class: message).
My goal is to get the response_metadata into my logs. Here's one idea that I have for a feature in this library that would achieve that:
- Add a config option for verbose Web API errors (
verbose_web_api_errors?). - If this config option is set then the
messageonSlackErrorwill be the entire body as JSON, rather than just theerror. - The option would default to false so as to not break anyone's code.
SlackErrorwould also gain a new attribute, perhapserror, which would be the value oferrorfrom Slack's response, so that this is easily accessed even when the verbose option is being used.- For completeness,
SlackErrorwould also gain a new attributeresponse_metadatacontaining just theresponse_metadata(as a hash-like object).
What do you think of this approach? I don't know much about logging, so maybe there's a better approach to this, either within this library or simply in my own app.
- Dominant language
- Ruby
- Stars
- 1.3k
- Forks
- 222
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from slack-ruby/slack-ruby-client
-
new feature question
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
slack-ruby/slack-ruby-client#586 · 3 comments ·
-
bug?
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
slack-ruby/slack-ruby-client#579 · 3 comments ·
-
new feature web api
Difficulty 3/5 1-2 days Newbie friendliness 42/100
slack-ruby/slack-ruby-client#482 · 5 comments ·
-
new feature
Difficulty 4/5 3-5 days Newbie friendliness 35/100
slack-ruby/slack-ruby-client#414 · 14 comments ·
-
confirmed bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
slack-ruby/slack-ruby-client#409 · 5 comments ·
All issues in slack-ruby/slack-ruby-client
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bensheldon/good_job#1816 · 5 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·