Skip to content

fix: apply proxies to realtime, analytics and event requests - #291

Open
pcbeingused333 wants to merge 2 commits into
Flagsmith:mainfrom
pcbeingused333:fix/c6701-proxies-realtime-analytics
Open

pcbeingused333 wants to merge 2 commits into
Flagsmith:mainfrom
pcbeingused333:fix/c6701-proxies-realtime-analytics

Conversation

@pcbeingused333

Copy link
Copy Markdown

The proxies argument of Flagsmith is only set on the session used for flags, identities and the environment document. The realtime SSE stream (requests.get), the analytics flush and the event processor (its own session) never receive it, so behind a required proxy those requests try to connect directly.

This forwards proxies to EventStreamManager, AnalyticsProcessor and EventProcessor. Each new argument is optional and defaults to the previous behaviour. custom_headers is not changed here.

Testing and validation

  • Two new tests: one builds a client with realtime, analytics and events enabled and checks that all three receive the proxies; one checks they are set on the event processor session. Both fail on main and pass with this change.
  • Full suite: 404 passed, 6 failed. The 6 test_flagsmith__init__expected_headers_sent cases also fail on unmodified main in this local environment (Accept-Encoding includes zstd).
  • mypy, black, isort: clean.

This change was prepared with AI assistance.

The proxies passed to Flagsmith were only set on the session used for the
main API. Forward them to the SSE stream, the analytics flush and the
event processor too.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pcbeingused333
pcbeingused333 requested a review from a team as a code owner November 28, 2026 12:08
@pcbeingused333
pcbeingused333 requested review from emyller and removed request for a team November 28, 2026 12:08

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread tests/test_flagsmith.py Resolved
@pcbeingused333

Copy link
Copy Markdown
Author

Valid: stop() could run before the worker thread reached requests.get, leaving mock_get.call_args unset. The test now waits (bounded, 5 s) until the mocked SSE request is observed before stopping the stream, and the stop/join cleanup runs even if that wait fails. Both proxy tests pass.

This comment was drafted with Claude Code.

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.

1 participant