Files
a510a8e3a5 fix(microsoft-foundry): keep spawn pipe streams UTF-8 safe across chunk splits (#109499)
* fix(microsoft-foundry): decode spawn pipes statefully with setEncoding('utf8')

Co-Authored-By: SunnyShu0925 <sunny.shu0925@gmail.com>

child_process spawn stdout/stderr .on('data') handlers in
azLoginDeviceCodeWithOptions received raw Buffer chunks. When a
multi-byte UTF-8 code point straddled a chunk boundary, String(chunk)
produced U+FFFD (replacement characters) for the split partial
sequences.

Fix the same way as PR #108518 (provider-local-service) and #109220
(voice-call ngrok): call setEncoding('utf8') on the pipe streams before
attaching data listeners so Node's stream decoder reassembles full code
points across chunk boundaries.

Test: PassThrough stream that receives a 4-byte smiley (U+1F60A) split
mid-sequence across two Buffer writes. With setEncoding, the reassembled
output is the clean code point, not U+FFFD.

* test(microsoft-foundry): replace PassThrough test with azLoginDeviceCodeWithOptions regression

* test(microsoft-foundry): add real-spawn integration test for split-byte setEncoding proof

* fix: add :unknown to catch callback variable for oxlint

* chore: add proof script for setEncoding utf8 split-byte fix

* remove standalone proof script (proof lives in PR body + test coverage)

* test(microsoft-foundry): tighten UTF-8 stream regression

Co-authored-by: SunnyShu0925 <shu.zongyu@xydigit.com>

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-20 18:51:12 -07:00
..