Skip to content

Conversation

maxi297
Copy link
Contributor

@maxi297 maxi297 commented Sep 30, 2025

What

Following this change, regression tests (or anything run having noproxy as a env and querying another domain than what is defined in noproxy will cause a NoneType exception

How

Pass a dict if proxies is not defined

Summary by CodeRabbit

  • New Features

    • None
  • Bug Fixes

    • Default proxy settings now reliably use an explicit empty proxy value when none are provided, avoiding unexpected failures.
    • HTTPS certificate verification now honors the environment/system CA bundle configuration.
  • Tests

    • Added tests for proxy bypass scenarios.
    • Added tests ensuring custom CA bundle settings are respected.
  • Other

    • No changes to public interfaces.

@github-actions github-actions bot added bug Something isn't working security labels Sep 30, 2025
Copy link

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

Testing This CDK Version

You can test this version of the CDK using the following:

# Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@maxi297/fix_bug_in_no_proxy#egg=airbyte-python-cdk[dev]' --help

# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch maxi297/fix_bug_in_no_proxy

Helpful Resources

PR Slash Commands

Airbyte Maintainers can execute the following slash commands on your PR:

  • /autofix - Fixes most formatting and linting issues
  • /poetry-lock - Updates poetry.lock file
  • /test - Runs connector tests with the updated CDK
  • /poe build - Regenerate git-committed build artifacts, such as the pydantic models which are generated from the manifest JSON schema in YAML.
  • /poe <command> - Runs any poe command in the CDK environment

📝 Edit this welcome message.

@maxi297
Copy link
Contributor Author

maxi297 commented Sep 30, 2025

/autofix

Auto-Fix Job Info

This job attempts to auto-fix any linting or formating issues. If any fixes are made,
those changes will be automatically committed and pushed back to the PR.

Note: This job can only be run by maintainers. On PRs from forks, this command requires
that the PR author has enabled the Allow edits from maintainers option.

PR auto-fix job started... Check job output.

✅ Changes applied successfully.

Copy link
Contributor

coderabbitai bot commented Sep 30, 2025

📝 Walkthrough

Walkthrough

send_request now ensures proxies is an explicit empty dict when absent in request_kwargs. Two unit tests were added: one verifying no_proxy behavior across different URLs and one ensuring REQUESTS_CA_BUNDLE causes verify to be passed into _send_with_retry.

Changes

Cohort / File(s) Summary
HTTP client proxy defaulting
airbyte_cdk/sources/streams/http/http_client.py
send_request now defaults environment_settings["proxies"] to {} if not provided in request_kwargs; other environment settings unchanged.
Unit tests for proxy and CA bundle
unit_tests/sources/streams/http/test_http_client.py
Added tests: (1) no_proxy pointing to another URL does not break sending a request to a different host when use_cache enabled; (2) REQUESTS_CA_BUNDLE results in verify being forwarded into _send_with_retry.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • brianjlai

Would you like me to add a short note in the client docs about the explicit empty-proxies default for clarity, wdyt?

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title clearly and concisely describes the main change, indicating that it fixes the noproxy issue which was causing regression tests to break, and it accurately reflects the core purpose of the PR without extraneous details.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch maxi297/fix_bug_in_no_proxy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
unit_tests/sources/streams/http/test_http_client.py (1)

1-1: Fix the formatting issue detected by ruff.

The linter detected that this file needs reformatting. Please run ruff format on this file to fix the code style issues.

Run the following command to fix:

ruff format unit_tests/sources/streams/http/test_http_client.py
🧹 Nitpick comments (1)
unit_tests/sources/streams/http/test_http_client.py (1)

750-764: Consider cleaning up the environment variable and strengthening the assertion.

A few suggestions to make this test more robust:

  1. The no_proxy environment variable is set but never cleaned up, which could affect other tests. Consider using @patch.dict("os.environ", {"no_proxy": "another.com"}) decorator instead (similar to the test at line 766), wdyt?

  2. The variable name x is not descriptive—maybe request, response to match the return type?

  3. The assertion assert x just checks truthiness. Would it be clearer to assert on the response more specifically, like assert response.status_code == 200 or assert response.json()["test"] == "a response"?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25132b6 and 7127624.

📒 Files selected for processing (2)
  • airbyte_cdk/sources/streams/http/http_client.py (1 hunks)
  • unit_tests/sources/streams/http/test_http_client.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
airbyte_cdk/sources/streams/http/http_client.py (1)
airbyte_cdk/sources/streams/http/http.py (1)
  • request_kwargs (242-253)
unit_tests/sources/streams/http/test_http_client.py (1)
airbyte_cdk/sources/streams/http/http_client.py (2)
  • name (533-534)
  • send_request (536-579)
🪛 GitHub Actions: Linters
unit_tests/sources/streams/http/test_http_client.py

[error] 1-1: ruff format check detected that the file would be reformatted. Run 'ruff format' to fix code style issues.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Manifest Server Docker Image Build
  • GitHub Check: Check: source-pokeapi
  • GitHub Check: Check: destination-motherduck
  • GitHub Check: Check: source-hardcoded-records
  • GitHub Check: Check: source-intercom
  • GitHub Check: Check: source-shopify
  • GitHub Check: Pytest (All, Python 3.12, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.13, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Analyze (python)
🔇 Additional comments (1)
airbyte_cdk/sources/streams/http/http_client.py (1)

565-565: LGTM! The fix correctly prevents the NoneType exception.

Defaulting proxies to an empty dict when not provided ensures that merge_environment_settings always receives a dict, which prevents the exception when no_proxy is set. This is a minimal and targeted fix that directly addresses the regression from PR 755.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
unit_tests/sources/streams/http/test_http_client.py (1)

750-762: Clean up the environment variable and improve variable naming, wdyt?

This test validates the no_proxy fix, which is great! A couple of suggestions:

  1. The no_proxy environment variable is set but never cleaned up, which could interfere with other tests. Consider using @patch.dict("os.environ", {"no_proxy": "another.com"}) as a decorator (similar to line 764) to ensure automatic cleanup.

  2. The variable name x on line 759 is quite generic. Consider using something more descriptive like request_response_tuple or result.

Apply this diff to improve the test:

+@patch.dict("os.environ", {"no_proxy": "another.com"})
 def test_given_noproxy_for_another_url_when_send_request_then_do_not_break(requests_mock):
     http_client = HttpClient(name="test", logger=MagicMock(), use_cache=True)
-    os.environ["no_proxy"] = "another.com"
     requests_mock.register_uri(
         "GET",
         "https://google.com/",
         json={"test": "a response"},
     )
 
-    x = http_client.send_request("GET", "https://google.com/", request_kwargs={})
+    result = http_client.send_request("GET", "https://google.com/", request_kwargs={})
 
-    assert x
+    assert result
+    assert isinstance(result, tuple)
+    assert len(result) == 2
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7127624 and 8ba271e.

📒 Files selected for processing (1)
  • unit_tests/sources/streams/http/test_http_client.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
unit_tests/sources/streams/http/test_http_client.py (1)
airbyte_cdk/sources/streams/http/http_client.py (2)
  • name (533-534)
  • send_request (536-579)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Check: destination-motherduck
  • GitHub Check: Check: source-shopify
  • GitHub Check: Check: source-pokeapi
  • GitHub Check: Check: source-intercom
  • GitHub Check: Check: source-hardcoded-records
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Manifest Server Docker Image Build
  • GitHub Check: Pytest (All, Python 3.13, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.12, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (Fast)
🔇 Additional comments (1)
unit_tests/sources/streams/http/test_http_client.py (1)

764-781: LGTM! The test properly validates REQUESTS_CA_BUNDLE handling.

This test is well-structured with proper environment variable patching and clear assertions. The use of @patch.dict ensures clean teardown, and mocking _send_with_retry is an effective way to verify that environment settings are merged correctly.

Optional suggestion: The test name mentions "environment variables" (plural), but it only verifies REQUESTS_CA_BUNDLE. If you'd like to test additional environment variables (like HTTP_PROXY, HTTPS_PROXY, etc.), you could parameterize this test or add separate test cases, wdyt?

Copy link

PyTest Results (Fast)

3 773 tests  +1   3 761 ✅ +1   6m 15s ⏱️ ±0s
    1 suites ±0      12 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 8ba271e. ± Comparison against base commit 25132b6.

Copy link

PyTest Results (Full)

3 776 tests  +1   3 764 ✅ +1   10m 55s ⏱️ -7s
    1 suites ±0      12 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 8ba271e. ± Comparison against base commit 25132b6.

@maxi297 maxi297 merged commit 8a01e33 into main Sep 30, 2025
28 of 29 checks passed
@maxi297 maxi297 deleted the maxi297/fix_bug_in_no_proxy branch September 30, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants