Skip to content

Fix #1082 by ignoring proxy parameter if env parameter is set but empty#1083

Merged
seratch merged 3 commits intoslackapi:mainfrom
y-adachi-00one:fix-issue-1082
Aug 17, 2021
Merged

Fix #1082 by ignoring proxy parameter if env parameter is set but empty#1083
seratch merged 3 commits intoslackapi:mainfrom
y-adachi-00one:fix-issue-1082

Conversation

@y-adachi-00one
Copy link
Copy Markdown
Contributor

Summary

Fix #1082

Category (place an x in each of the [ ])

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs-src (Documents, have you run ./docs.sh?)
  • /docs-src-v2 (Documents, have you run ./docs-v2.sh?)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements (place an x in each [ ])

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

@gitwave gitwave bot added the untriaged label Aug 4, 2021
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Aug 4, 2021

CLA assistant check
All committers have signed the CLA.

)
if proxy_url is None or len(proxy_url.strip()) == 0:
# If the value is an empty string, the intention should be unsetting it
if len(proxy_url.strip()) == 0:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line does not work if the proxy_url is None. Can you verify it with a new test pattern in tests/test_proxy_env_variable_loader.py?

>>> proxy_url = None
>>> len(proxy_url.strip())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'strip'

How about doing this way?

    if proxy_url is None:
        return None
    if len(proxy_url.strip()) == 0:
        # If the value is an empty string, the intention should be unsetting it
        logger.debug("...")
        return None

if proxy_url is None or len(proxy_url.strip()) == 0:
# If the value is an empty string, the intention should be unsetting it
if len(proxy_url.strip()) == 0:
logger.debug("HTTP proxy env variable is set but empty")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps, telling what happened would be more informative:

Suggested change
logger.debug("HTTP proxy env variable is set but empty")
logger.debug("The Slack SDK ignored the proxy env variable as an empty value is set.")

url = load_http_proxy_from_env()
self.assertEqual(url, "http://localhost:9999")

def test_load_all_empty_case(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add one more test with None values?

@seratch seratch added enhancement M-T: A feature request for new functionality Version: 3x web-client and removed untriaged labels Aug 4, 2021
@seratch seratch added this to the 3.9.0 milestone Aug 4, 2021
@seratch
Copy link
Copy Markdown
Contributor

seratch commented Aug 4, 2021

@y-adachi-00one Would you mind signing our CLA? Without having it, we are unable to merge your contribution to this project. See the above bot comment for details.

@seratch seratch modified the milestones: 3.9.0, 3.10.0 Aug 7, 2021
@seratch seratch marked this pull request as draft August 7, 2021 02:36
@seratch
Copy link
Copy Markdown
Contributor

seratch commented Aug 10, 2021

Hi @y-adachi-00one, thanks for signing the CLA! No rush at all but could you update this pull request if you have a chance?

@y-adachi-00one
Copy link
Copy Markdown
Contributor Author

I'm sorry for late. I'll modify that according to your advice. Could you give me a little time?

@seratch
Copy link
Copy Markdown
Contributor

seratch commented Aug 10, 2021

No rush at all. We're going to release v3.9 very soon but your changes can be included later on (v3.10 or later)!

@y-adachi-00one
Copy link
Copy Markdown
Contributor Author

@seratch Thank you for reviewing. I fixed my code according to your advice.
Could you re-review my update?

@seratch seratch marked this pull request as ready for review August 17, 2021 01:40
Copy link
Copy Markdown
Contributor

@seratch seratch left a comment

Choose a reason for hiding this comment

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

Looks great to me! Once the CI builds pass, we will merge this PR 👍

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 17, 2021

Codecov Report

Merging #1083 (edde490) into main (c678018) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1083      +/-   ##
==========================================
- Coverage   86.07%   86.06%   -0.02%     
==========================================
  Files         110      110              
  Lines        9932     9936       +4     
==========================================
+ Hits         8549     8551       +2     
- Misses       1383     1385       +2     
Impacted Files Coverage Δ
slack_sdk/proxy_env_variable_loader.py 100.00% <100.00%> (ø)
slack_sdk/socket_mode/builtin/client.py 79.19% <0.00%> (-0.68%) ⬇️
slack_sdk/socket_mode/builtin/connection.py 35.71% <0.00%> (-0.43%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c678018...edde490. Read the comment docs.

@seratch seratch merged commit c496631 into slackapi:main Aug 17, 2021
@seratch seratch modified the milestones: 3.10.0, 3.9.1 Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality Version: 3x web-client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"urlopen error no host given" occurred by referring to an empty proxy env params

3 participants