Skip to content

Ensure proxies and timeout options are handled correctly#10

Merged
richdawe-cio merged 5 commits into
mainfrom
cdp-6173-proxy-timeout-bugs
Jun 30, 2026
Merged

Ensure proxies and timeout options are handled correctly#10
richdawe-cio merged 5 commits into
mainfrom
cdp-6173-proxy-timeout-bugs

Conversation

@richdawe-cio

@richdawe-cio richdawe-cio commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • The proxies option on the Client constructor was accepted but never actually passed to the underlying requests session. The post() function in request.py built a kwargs dict containing proxies, but then called _session.post() with individual named arguments instead of using that dict.
  • Fixed by calling _session.post(url, **kwargs) so all options (including proxies) flow through.
  • Also fixed a latent bug where timeout was hardcoded to 15 in the kwargs dict instead of using the timeout parameter.
  • Replaced the existing proxy tests (which didn't actually verify proxies reached the HTTP layer) with tests that mock _session.post and assert proxies is present in the call arguments.

Test plan

  • test_proxies_passed_to_session — verifies proxies dict reaches _session.post via post()
  • test_no_proxies_by_default — verifies proxies is omitted when not set
  • TestClient.test_proxies — verifies proxies flows end-to-end from Client constructor through to _session.post
  • Full test suite passes

I made these changes.

🤖 Generated with Claude Code


Note

Medium Risk
Changes affect all batch uploads (timeout/proxy behavior); fixes are straightforward but touch the critical outbound HTTP path customers rely on.

Overview
HTTP upload options were silently ignored: post() built a kwargs dict with proxies and timeout but called _session.post() with separate arguments, so Client proxy settings never reached the wire. The call now uses _session.post(url, **kwargs), and the request kwargs use the timeout parameter instead of a hardcoded 15. proxies is only added when not None.

Proxy-related tests now mock _session.post and assert proxies is present or omitted; consumer proxy coverage checks stored config. Minor test tweaks add upload_interval coverage and stabilize batch timing. AGENTS.md documents opening PRs against customerio/cdp-analytics-python; CLAUDE.md points agents at that file.

Reviewed by Cursor Bugbot for commit 44600a0. Bugbot is set up for automated code reviews on this repo. Configure here.

@sydneycollins-cio sydneycollins-cio left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, minor nits inline.

Comment thread customerio/analytics/request.py Outdated
"timeout": timeout,
}

if proxies:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Non-blocking. proxies is only added to kwargs when truthy, so proxies={} silently drops it while the other options are always included. Either document that an empty dict means no proxy, or use if proxies is not None to be explicit.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

OK will make this explicit

def test_user_defined_upload_size(self):
client = Client('testsecret', on_error=self.fail,
upload_size=10, upload_interval=3)
upload_size=10, upload_interval=0.3)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Non-blocking. Is the upload_interval=30.3 change intentional? Looks unrelated to the proxy/timeout fix — if it is a test speed improvement, a comment would make it clear.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will add comment, thanks.

@richdawe-cio richdawe-cio merged commit 776e23b into main Jun 30, 2026
11 checks passed
@richdawe-cio richdawe-cio deleted the cdp-6173-proxy-timeout-bugs branch June 30, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants