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

Add client callback for API warning messages #905

Closed
wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Mar 5, 2021

Problem: There's no way to surface Slack's API warnings in application code from the library.

This PR exposes a new client Option that registers a callback for every response that comes back with warning information. This suits the use case for logging/tracking warnings as they appear, without affecting the request/response interface of each endpoint. The nodejs sdk seems to take a similar approach.

onWarning := func(warning *slack.Warning, path string, values url.Values) {
  // Log the warning here.
}
client := slack.New(token, slack.OptionOnWarning(onWarning))

An easy way to test this and see warnings is to update outgoing headers to have ; charset=utf-8 at the end.

Relevant docs/reading:

ryannjohnson-range added 2 commits February 26, 2021 03:12
The Slack web api returns a "warning" property on response objects. The
requests succeed, but this field will return a comma-separated list of
warning codes that range from "superfluous_charset" to
"method_deprecated", as well as extra messages in the
.response_metadata.warnings property.

This option allows applications to get notified when these warnings
exist.
@ghost
Copy link
Author

ghost commented Mar 19, 2021

Closing to keep downstream changes from appearing in this PR.

@ghost ghost closed this Mar 19, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants