Skip to content

fix: accept a UTF-8 BOM in an @file --data payload - #34

Merged
igor-ctrl merged 2 commits into
mainfrom
fix/bom-tolerant-data
Aug 12, 2026
Merged

fix: accept a UTF-8 BOM in an @file --data payload#34
igor-ctrl merged 2 commits into
mainfrom
fix/bom-tolerant-data

Conversation

@igor-ctrl

Copy link
Copy Markdown
Owner

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 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.

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.
@igor-ctrl
igor-ctrl merged commit 65ec551 into main Aug 12, 2026
3 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.

1 participant