fix(tools): close S3 response body in S3ReaderTool - #7654
FanouZeng-TT wants to merge 1 commit into
Conversation
The get_object() response body was never closed, so successful reads and decode failures both left the underlying HTTP response open for garbage collection. Wrap read/decode in try/finally so the body is closed exactly once on every path.
|
This PR was prepared with AI assistance. Per the contributing requirements it needs the |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesS3 response body cleanup
Priority: ➖ Normal Severity of issue fixed: Medium 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Related issue
Fixes #7646
Summary
get_object()response body inS3ReaderToolso pooled HTTP connections are released deterministicallytry/finallyso the body is closed exactly once on success and on every failure pathThe body previously stayed open on every path, leaving cleanup to garbage collection and retaining pooled connections across repeated tool calls.
Verification
Tests added or updated for the changed behavior
Relevant tests and quality checks pass locally
uv run --frozen pytest lib/crewai-tools/tests/tools/s3_reader_tool_test.py -q— red baseline before the fix: 3 failed (success, decode failure, read failure), 1 passed (ClientError behavior baseline); after the fix: 4 passedruff checkon both changed files — passedTests are fully offline: a fake
boto3/botocoremodule pair is injected viamonkeypatch.setitem(sys.modules, ...), so neither the SDK nor network access is requiredAdditional context
This PR was prepared with AI assistance; please apply the
llm-generatedlabel (external contributors cannot add repository labels).🤖 Generated with Claude Code