Skip to content

fix(message): correctly concat base64-encoded data block deltas#31

Merged
DavdGao merged 2 commits into
agentscope-ai:mainfrom
qbc2016:bc/data-block-delta-concat-fi
Jun 2, 2026
Merged

fix(message): correctly concat base64-encoded data block deltas#31
DavdGao merged 2 commits into
agentscope-ai:mainfrom
qbc2016:bc/data-block-delta-concat-fi

Conversation

@qbc2016

@qbc2016 qbc2016 commented Jun 1, 2026

Copy link
Copy Markdown
Member

Description

DATA_BLOCK_DELTA was appended with naive string concatenation. When each delta is an independently base64-encoded chunk whose raw byte length isn't a multiple of 3, the per-chunk = padding gets spliced into the middle of the stream, corrupting the result on decode.

Fix: decode existing and incoming chunks, concat the raw bytes, and re-encode — so the accumulated value equals base64(concat(rawBytes)).

Test updated to use chunks that exercise mid-stream padding (AQI= + Aw==AQID); the old string-concat path would have silently passed before.

Checklist

Please check the following items before the code is ready to be reviewed.

  • This PR is linked to a related issue (see above)
  • Code has been formatted with pnpm format
  • Related documentation has been updated (e.g. links, examples, etc.)
  • All tests are passing (pnpm test)
  • Code is ready for review

@DavdGao DavdGao merged commit df6152c into agentscope-ai:main Jun 2, 2026
6 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