fix: accept a UTF-8 BOM in an @file --data payload - #34
Merged
Conversation
Windows PowerShell 5.1 writes a UTF-8 BOM for `Set-Content -Encoding utf8`, and `utf8NoBOM` only exists in PowerShell 6+. Reading the file as plain utf-8 made json.loads reject the payload with "Unexpected UTF-8 BOM" before any request went out — so the documented `-d @payload.json` workaround, which is the *recommended* way to pass a body on PowerShell because inline JSON gets mangled, failed on the exact platform it exists for. Reading as utf-8-sig strips a BOM when present and is identical to utf-8 when it is not, so this only ever accepts more input. Malformed JSON behind a BOM still reports cleanly.
uv sync --locked in CI failed before ruff or pytest ever ran because the version bump in this PR's pyproject.toml was never reflected in uv.lock, which pins the same version for the editable root package.
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.
fix(cli): accept a UTF-8 BOM in an @file --data payload
Windows PowerShell 5.1 writes a UTF-8 BOM for
Set-Content -Encoding utf8,and
utf8NoBOMonly exists in PowerShell 6+. Reading the file as plain utf-8made json.loads reject the payload with "Unexpected UTF-8 BOM" before any
request went out — so the documented
-d @payload.jsonworkaround, which isthe recommended way to pass a body on PowerShell because inline JSON gets
mangled, failed on the exact platform it exists for.
Reading as utf-8-sig strips a BOM when present and is identical to utf-8 when
it is not, so this only ever accepts more input. Malformed JSON behind a BOM
still reports cleanly.