Skip to content

fix(dataagent): strip POSIX base64 line wraps when downloading files - #4325

Merged
jujn merged 1 commit into
agentscope-ai:mainfrom
c020627:fix-dataagent-base64-download-wrap
Nov 22, 2026
Merged

jujn merged 1 commit into
agentscope-ai:mainfrom
c020627:fix-dataagent-base64-download-wrap

Conversation

@c020627

@c020627 c020627 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Problem

SharedSandboxFilesystem.downloadFiles() runs base64 <path> inside the sandbox and decodes stdout with the strict Base64.getDecoder(). POSIX base64 inserts a \n every 76 columns, so any payload larger than ~57 bytes contains embedded newlines. .trim() removes only leading/trailing whitespace, so the embedded newlines survive and the strict decoder rejects them.

The exception is caught and converted into a FileDownloadResponse.fail(...), so downloading any moderately sized binary file from a shared sandbox silently fails with Illegal base64 character ....

The sibling BaseSandboxFilesystem already handles this by stripping all whitespace before decoding (#3966).

Fix

Strip all whitespace from stdout with replaceAll("\\s+", "") before strict decoding, matching the sibling implementation. Also guard against a null stdout.

Test

SharedSandboxFilesystemTest feeds a MIME-wrapped base64 payload (76-column line wraps) from a mocked sandbox. Before the fix the response carries error = "Illegal base64 character a"; after the fix the decoded bytes match the original 128-byte payload.

Verification

  • Targeted test: pass
  • Module full suite: pass
  • Spotless: pass

@jujn
jujn merged commit 0226428 into agentscope-ai:main Nov 22, 2026
4 of 5 checks passed
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.

2 participants