fix(s3): default to s3v4 signature when no config is provided#50
fix(s3): default to s3v4 signature when no config is provided#50
Conversation
- Default `s3_config` to `Config(signature_version="s3v4")` in `S3Session` when none is supplied - Add `AGENTS.md` to `.gitignore`
WalkthroughTwo files modified: Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tracktolib/s3/niquests.py`:
- Around line 218-225: The code currently constructs a fallback
Config(signature_version="s3v4") only for passing into
self._botocore_session.create_client, leaving self.s3_config as None; update the
logic so that if self.s3_config is None you assign that fallback Config to
self.s3_config before calling self._botocore_session.create_client (i.e., set
self.s3_config = Config(signature_version="s3v4") and then call create_client
with config=self.s3_config) while keeping the existing endpoint_url and region
arguments (self.endpoint_url, self.region).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a01a7533-f1e8-4f2d-8a66-5c08ec2a766c
📒 Files selected for processing (2)
.gitignoretracktolib/s3/niquests.py
| config = self.s3_config | ||
| if config is None: | ||
| config = Config(signature_version="s3v4") | ||
| self.s3_client = self._botocore_session.create_client( | ||
| "s3", | ||
| endpoint_url=self.endpoint_url, | ||
| region_name=self.region, | ||
| config=self.s3_config, | ||
| config=config, |
There was a problem hiding this comment.
Persist the fallback config on self.s3_config.
Lines 218-225 only pass the derived Config(signature_version="s3v4") into create_client, so session.s3_config still ends up as None. That leaves the public session state inconsistent with the effective client config and doesn’t fully implement the PR’s stated “default s3_config” behavior.
Suggested fix
if self.s3_client is None:
self._botocore_session = botocore.session.Session()
if self.access_key is not None and self.secret_key is not None:
self._botocore_session.set_credentials(self.access_key, self.secret_key)
- config = self.s3_config
- if config is None:
- config = Config(signature_version="s3v4")
+ if self.s3_config is None:
+ self.s3_config = Config(signature_version="s3v4")
self.s3_client = self._botocore_session.create_client(
"s3",
endpoint_url=self.endpoint_url,
region_name=self.region,
- config=config,
+ config=self.s3_config,
)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| config = self.s3_config | |
| if config is None: | |
| config = Config(signature_version="s3v4") | |
| self.s3_client = self._botocore_session.create_client( | |
| "s3", | |
| endpoint_url=self.endpoint_url, | |
| region_name=self.region, | |
| config=self.s3_config, | |
| config=config, | |
| if self.s3_config is None: | |
| self.s3_config = Config(signature_version="s3v4") | |
| self.s3_client = self._botocore_session.create_client( | |
| "s3", | |
| endpoint_url=self.endpoint_url, | |
| region_name=self.region, | |
| config=self.s3_config, |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tracktolib/s3/niquests.py` around lines 218 - 225, The code currently
constructs a fallback Config(signature_version="s3v4") only for passing into
self._botocore_session.create_client, leaving self.s3_config as None; update the
logic so that if self.s3_config is None you assign that fallback Config to
self.s3_config before calling self._botocore_session.create_client (i.e., set
self.s3_config = Config(signature_version="s3v4") and then call create_client
with config=self.s3_config) while keeping the existing endpoint_url and region
arguments (self.endpoint_url, self.region).
s3_configtoConfig(signature_version="s3v4")inS3Sessionwhen none is suppliedAGENTS.mdto.gitignoreSummary by CodeRabbit
Bug Fixes
Chores