Repository navigation
fix(cli): read @file arguments saved as UTF-16LE or with a byte-order mark - #10298
Merged
waleedlatif1 merged 1 commit intoNov 21, 2026
Merged
Conversation
… mark Windows PowerShell 5.1 writes `>` redirects as UTF-16LE with a byte-order mark, and `Out-File -Encoding utf8` writes UTF-8 with one. The documented `sim workflows export ... > workflow.json` then `workflows import-preview --workflow @workflow.json` failed there with "--workflow must be valid JSON". @file and @- input is now decoded as UTF-16LE when it starts with that mark, and a leading mark is dropped either way, as the embedded reader's TextDecoder already does.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
[Medium impact] The PR appears safe to merge. SummaryAdds BOM-aware decoding for local
Reviews (1) · Last reviewed commit: "fix(cli): read @file arguments saved as ..." · Reviewed by Greptile |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Windows PowerShell 5.1, the shell Windows opens by default, writes
>redirects as UTF-16LE with a byte-order mark, andOut-File -Encoding utf8writes UTF-8 with one. The CLI read every@file/@-argument as plain UTF-8, so the documented export and import steps from the workflow sync guide fail there:readArgumentDescriptornow decodes the bytes as UTF-16LE when they start with that mark, and drops a leading mark in either encoding. That's what the embedded reader'sTextDecoderalready does with a UTF-8 mark. Input without a mark decodes exactly as before, and CRLF and trailing newlines are untouched.Type of Change
Testing
runtime/request.test.tsreads@pathsaved as UTF-16LE and as UTF-8 with a mark. Both fail onstagingwith the error above and pass with the change.Buffer#toString('utf8')andTextDecoder('utf-8')gave identical strings for 40,000 random and corrupted inputs in a throwaway comparison (invalid bytes, CRLF, multibyte characters).src/runtime,src/transferandcommands/secrets.test.tsgive the same results as onstagingapart from the new case (Windows 11). Biome,tsc --noEmitfor sim-cli,check:comment-hygieneandcheck:test-patternspass.-NoProfile), I built the CLI from both branches and pointed it at a closed local port. I wroteworkflow.jsonwith>and ranworkflows import-preview --workflow @workflow.json.stagingstops with the JSON error. With the change it reads the file and gets as far as the request (Could not reach http://127.0.0.1:9).Checklist