Skip to content

fix: remove double-base64 encoding in upload_file/download_file#464

Open
Hweinstock wants to merge 1 commit intoaws:mainfrom
Hweinstock:fix/double-base64-upload-download
Open

fix: remove double-base64 encoding in upload_file/download_file#464
Hweinstock wants to merge 1 commit intoaws:mainfrom
Hweinstock:fix/double-base64-upload-download

Conversation

@Hweinstock
Copy link
Copy Markdown
Contributor

Issue

Fixes #458

Description

upload_file/upload_files redundantly base64-encode bytes before passing to botocore's blob shape (which encodes again). download_file/download_files redundantly base64-decode the response blob that botocore already decoded. Binary files are corrupted on upload and crash or return garbage on download.

Changes

  • Remove base64.b64encode() in upload_file/upload_files — pass raw bytes to botocore
  • Remove base64.b64decode() in download_file/download_files — use botocore's already-decoded bytes
  • Remove unused import base64
  • Update unit tests to assert correct behavior (raw bytes, not pre-encoded strings)
  • Add integration test verifying binary roundtrip (test_code_interpreter_client.py)

Testing

  • Unit tests: uv run pytest tests/ -k code_interpreter — all pass
  • Integration tests: uv run pytest tests_integ/tools/test_code_interpreter_client.py -xvs — binary upload/download roundtrip verified against live service

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@d69db93). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #464   +/-   ##
=======================================
  Coverage        ?   89.40%           
=======================================
  Files           ?       82           
  Lines           ?     7570           
  Branches        ?     1132           
=======================================
  Hits            ?     6768           
  Misses          ?      511           
  Partials        ?      291           
Flag Coverage Δ
unittests 89.40% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Hweinstock Hweinstock force-pushed the fix/double-base64-upload-download branch from cc1de4c to 9742a05 Compare May 8, 2026 12:33
@Hweinstock Hweinstock force-pushed the fix/double-base64-upload-download branch from 9742a05 to d267bd7 Compare May 8, 2026 12:35
@Hweinstock Hweinstock force-pushed the fix/double-base64-upload-download branch from d267bd7 to 7484fb7 Compare May 8, 2026 12:39
@Hweinstock Hweinstock marked this pull request as ready for review May 8, 2026 12:42
@Hweinstock Hweinstock requested a review from a team May 8, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CodeInterpreter.upload_file / download_file double-base64 binary content (boto3 already handles blob shapes)

2 participants