Skip to content

fix: strip BOM and whitespace from authorization token - #757

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/strip-bom-token
Open

fix: strip BOM and whitespace from authorization token#757
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/strip-bom-token

Conversation

@sentry

@sentry sentry Bot commented Aug 9, 2026

Copy link
Copy Markdown

This PR addresses a UnicodeEncodeError that occurred when the Codecov CLI attempted to send an Authorization header containing a Byte Order Mark (BOM) character (\ufeff).

The error, "UnicodeEncodeError: 'latin-1' codec can't encode character '\ufeff'", was triggered because urllib3 (used by requests) attempts to encode HTTP headers using latin-1, which does not support the \ufeff character.

The root cause was identified as the token string, often provided via CLI arguments or environment variables, sometimes containing a leading \ufeff character (e.g., from copy-pasting from certain sources or specific file encodings). The CLI was using this token verbatim when constructing the Authorization header.

To fix this, the get_token_header and get_token_header_or_fail functions in codecov_cli/helpers/request.py have been updated to strip the \ufeff character and any surrounding whitespace from the token string before it is used to form the Authorization header. This ensures that only valid, encodable characters are passed to the HTTP client.

Fixes CLI-EP

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.

0 participants