mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-13 00:05:02 -05:00
fix: Use format='bytes' for reading binary files from E2B sandbox
Fixes the critical bug where binary files would fail to read because files.read() defaults to text mode (UTF-8 decoding). Now explicitly uses format='bytes' which returns a bytearray.
This commit is contained in:
@@ -651,10 +651,11 @@ class ClaudeCodeBlock(Block):
|
||||
pass
|
||||
elif is_binary:
|
||||
try:
|
||||
# Read binary file as bytes
|
||||
content_bytes = await sandbox.files.read(file_path)
|
||||
if isinstance(content_bytes, str):
|
||||
content_bytes = content_bytes.encode("utf-8")
|
||||
# Read binary file as bytes using format="bytes"
|
||||
# This returns bytearray, avoiding UTF-8 decoding issues
|
||||
content_bytes = await sandbox.files.read(
|
||||
file_path, format="bytes"
|
||||
)
|
||||
|
||||
# Base64 encode the binary content
|
||||
content_b64 = base64.b64encode(content_bytes).decode(
|
||||
|
||||
Reference in New Issue
Block a user