slackapi/python-slack-sdk

Error Logging: Failed to send a request to Slack API server: <urlopen error [Errno 0] Error>

akancha12 opened this issue · 4 comments

Reproducible in:

pip freeze | grep slack
python --version
sw_vers && uname -v # or `ver`

The Slack SDK version

3.20.2

Python runtime version

3.7.10

OS info

anything would work

ProductName:	macOS
ProductVersion:	12.6
BuildVersion:	21G115
Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000

Steps to reproduce:

While making lookupByEmail call, it is sometimes logging url error by urllib library as follows:

Failed to send a request to Slack API server: <urlopen error [Errno 0] Error>

which is getting unnecessarily logged in sentry.

Expected result:

Should not get logged in sentry

Actual result:

Getting logged in sentry even though no exception is raised

Requirements

For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Hi @akancha12, thanks for writing in.

In this scenario, it seems that your API call fails on the first attempt, and then the WebClient's built-in connection error retry handler manages to resend the same request. The error logging might create some confusion for you, but the connection issue within your network (or somewhere between Slack and your infra) likely persists. Therefore, I believe it's still reasonable to log the error from the first attempt.

If all retries fail, WebClient will throw an exception in your app code. Thus, on the Sentry side, you can mark the pattern you reported here as one that can be ignored.

I hope this helps.

Yeah, makes sense. It gets auto resolved every time after going into retry handler. Mind suggesting some scenarios for the connection error that occurred?

It seems this error is occurring during the initial connection establishment with the Slack API. This could happen due to:

  • transient network errors
  • SSL handshake errors, which could happen if you have a proxy in place that is not properly configured for TLS
  • unable to resolve the slack.com hostname

Thanks