Skip to content

fix: strip BOM from authorization token - #784

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

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

Conversation

@sentry

@sentry sentry Bot commented Sep 8, 2026

Copy link
Copy Markdown

This PR addresses a UnicodeEncodeError that occurred when the authorization token contained a Byte Order Mark (BOM) character (\ufeff).

Problem: Users encountered UnicodeEncodeError: 'latin-1' codec can't encode character '\ufeff' during coverage uploads, specifically when the token provided (e.g., from an environment variable or file) included a leading BOM.

Root Cause: The codecov_cli/helpers/request.py module, in functions get_token_header_or_fail and get_token_header, was directly using the raw token string to construct the Authorization header. This unsanitized token, when containing \ufeff, caused urllib3 to fail during header encoding as latin-1 cannot represent this character.

Solution: The fix involves stripping the BOM character (\ufeff) and any leading/trailing whitespace from the token using token.strip("\ufeff").strip() before it is used to form the Authorization header. This ensures that only valid, encodable characters are passed to the HTTP request library.

Fixes CLI-EP

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
723 1 722 1
View the full list of 1 ❄️ flaky test(s)
api.temp.calculator.test_calculator::test_divide

Flake rate in main: 100.00% (Passed 0 times, Failed 1726 times)

Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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