Repository navigation
[FSSDK-13482] Fix Arnica findings: setup.py exec and http session mount - #529
Open
Esra Kartal (esrakartalOpt) wants to merge 3 commits into
Open
Esra Kartal (esrakartalOpt) wants to merge 3 commits into
Esra Kartal (esrakartalOpt) wants to merge 3 commits into
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>
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://, andretriesstaysOptional[int]as before.http://mount is kept on purpose. The SDK defaults are allhttps://, but users can configure a customhttp://datafile URL or event endpoint (for example an internal proxy or a local test server), and dropping the mount would silently remove retries for them. 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.testmatrix inpython.yml. Python 3.9 reached end of life in October 2025, andsetup-pythonno longer finds a 3.9 build onubuntu-latest(now Ubuntu 26.04), sotest (3.9)failed before running any tests. This was a pre-existing failure onmaster, not caused by the other changes.Test plan
python -m pytest tests: 1047 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://python setup.py --versionprints5.8.0, same asoptimizely.version.__version__Issues
🤖 Generated with Claude Code