Repository navigation
[FSSDK-13482] Fix Arnica findings: setup.py exec and http session mount - #529
Merged
Esra Kartal (esrakartalOpt) merged 5 commits intoNov 23, 2026
Merged
Conversation
- setup.py: read the version by parsing the version_info literal from
optimizely/version.py instead of exec()-ing the file.
- Add create_retry_session helper and use it in event_dispatcher and
config_manager, replacing three duplicated session.mount('http://', ...)
blocks with one documented, suppressed call. Behavior is unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
config_manager passes self.retries, which is Optional[int]. Accept Optional[int] (None means no total limit, same as urllib3's Retry) so type-check passes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Python 3.9 reached end of life in October 2025 and setup-python no longer finds a 3.9 build on ubuntu-latest (now Ubuntu 26.04), so the test (3.9) job failed before running any tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Farhan Anjum (FarhanAnjum-opti)
requested changes
Nov 23, 2026
Farhan Anjum (FarhanAnjum-opti)
left a comment
Contributor
There was a problem hiding this comment.
A few small changes requested inline: default status_forcelist, and remove the duplicated http:// explanation. Also, please update the PR description: it still says Python 3.9 is dropped from CI, but that was reverted and is now tracked in FSSDK-13301. The rest looks good: the setup.py change and the caller swaps behave the same as before.
…ed http:// note - Default status_forcelist to (500, 502, 503, 504) in create_retry_session and drop the argument from the three callers. - Keep the http:// explanation next to the mount call and shorten the docstring. - Add a test for the default status_forcelist. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Esra Kartal (esrakartalOpt)
requested a review
from Farhan Anjum (FarhanAnjum-opti)
November 23, 2026 16:25
Farhan Anjum (FarhanAnjum-opti)
approved these changes
Nov 23, 2026
Farhan Anjum (FarhanAnjum-opti)
left a comment
Contributor
There was a problem hiding this comment.
All comments addressed, thanks! LGTM 👍
The test (3.9) failure was already on master and will be fixed in FSSDK-13301.
Esra Kartal (esrakartalOpt)
deleted the
fssdk-13482-fix-arnica-findings
branch
November 23, 2026 17:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
setup.py: read the package version by parsing theversion_infotuple literal fromoptimizely/version.py(regex plusast.literal_eval) instead of callingexec()on the file (Arnica "Exec detected" finding). It raises a clear error ifversion_infois not found.python setup.py --versionstill prints5.8.0.optimizely/helpers/retry_session.pywithcreate_retry_session(...), and use it inevent_dispatcher.pyandconfig_manager.py(two places). This replaces three copies of the same retry session setup, including thesession.mount('http://', adapter)call that Arnica flags as "Request session with HTTP", with one documented call. Behavior is unchanged: the same retry adapter is still registered for bothhttps://andhttp://,retriesstaysOptional[int]as before, andstatus_forcelistdefaults to(500, 502, 503, 504), which all three callers used.http://mount is kept on purpose, so retries still apply to user-configuredhttp://datafile URLs and event endpoints (the SDK defaults are allhttps://). Registering an adapter does not send anything overhttp://. The call carries a barenosemgrepcomment, because the full rule id does not fit in the repo's 120 character line limit. If Arnica does not honor it, dismiss the finding there with the reason above.requestsimport fromevent_dispatcher.py.Notes
test (3.9)fails in CI becauseubuntu-latestis now Ubuntu 26.04, which has no Python 3.9 build forsetup-python. This is a pre-existing failure onmaster, not caused by this PR. Dropping Python 3.9 from the matrix is tracked separately in FSSDK-13301, so this PR does not change the CI matrix.optimizely/fullstack-prod-suite (python)also fails onmaster, at the "Configure AWS Credentials" step of that other repo's pipeline.Test plan
python -m pytest tests: 1048 passedruff check .andmypy . --exclude "tests/testapp"andmypy . --exclude "tests/" --strict: all passtests/helpers_tests/test_retry_session.py: the helper returns a session with the retry adapter (retries, backoff factor and status codes) on bothhttps://andhttp://, andstatus_forcelisthas the expected defaultpython setup.py --versionprints5.8.0, same asoptimizely.version.__version__Issues
🤖 Generated with Claude Code