fix: avoid shared mutable default args in GitHost helpers - #283
Closed
eve-ci-cd[bot] wants to merge 1 commit into
Closed
eve-ci-cd[bot] wants to merge 1 commit into
eve-ci-cd[bot] wants to merge 1 commit into
Conversation
GitHubClient._get() mutates the headers dict it receives
(kwargs.setdefault('headers', {}).update(...)). Since GitHostObject.get()
and list() defaulted to a single shared headers={} dict, conditional
request headers (If-None-Match / If-Modified-Since) were written into
state shared across every call and thread. Default to None and build a
fresh dict per call.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #283 +/- ##
==========================================
- Coverage 90.21% 90.19% -0.03%
==========================================
Files 82 82
Lines 11293 11299 +6
==========================================
+ Hits 10188 10191 +3
- Misses 1105 1108 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
GitHostObject.get/list/create/updateinbert_e/git_host/base.pyusedparams={}/headers={}as default arguments.GitHubClient._get()mutates the headers it receives (kwargs.setdefault('headers', {}).update(headers)), so the conditional-request headers (If-None-Match,If-Modified-Since) were written into one dict shared by all calls and all server threads.It is currently masked because the update overwrites both keys on every call, but it is a latent thread-safety/leak bug that would surface as soon as any other header is added.
Fix
Default to
Noneand create a fresh dict per call. No behaviour change otherwise.Testing
Unit tests pass locally (excluding
test_github_app_auth.py, which needs network access in my sandbox).🤖 Generated with Claude Code