Repository navigation
fix: ignore a UTF-8 BOM in the Vault token file - #117
Partha-Shankar wants to merge 1 commit into
Conversation
Read the refresh-token file with encoding="utf-8-sig" like the other text reads in the package. A BOM (e.g. from PowerShell 5.1 Set-Content -Encoding UTF8) was sent as part of the token. Adds a regression test.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Pull Request
Description
__get_vault_access__reads the Vault refresh-token file withopen(token_file, "r"). Without an explicit encoding Python uses the locale codec (cp1252 on Windows), and.strip()does not remove a UTF-8 byte-order mark. So a token file saved with a BOM (for example by Windows PowerShell 5.1Set-Content -Encoding UTF8) is sent to the token endpoint aseyJ…on Windows (eyJ…on Linux). The token request then fails and the download stops with arequests.HTTPError.This PR opens the file with
encoding="utf-8-sig", the encoding the other text reads in the package already use (cli.py,manifest/replay.py,workflow/parser.py,filehandling/format.py). Files without a BOM are read exactly as before.It also adds a parametrized test to
tests/test_download_auth.py(token file with and without a BOM,requests.postmocked) that checks the refresh token sent in the first token request. The BOM case fails onmainon Windows and on Linux.No version bump, following #103; I can add one if you want it.
Related Issues
No existing issue. Same kind of fix as #103 (UTF-8 BOM in CSV/TSV).
Type of change
Checklist:
pytest- all tests passed (280 passed, 3 skipped on Windows, Python 3.11, with and withoutPYTHONUTF8=1; I installed with pip instead of Poetry)ruff check- no linting errors (ruff 0.5.7)Summary by CodeRabbit