Skip to content

fix: strip whitespace from CODECOV_TOKEN in Authorization header - #742

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

fix: strip whitespace from CODECOV_TOKEN in Authorization header#742
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/strip-token-whitespace

Conversation

@sentry

@sentry sentry Bot commented Jul 27, 2026

Copy link
Copy Markdown

This PR addresses the InvalidHeader error (CLI-1R) that occurs when the CODECOV_TOKEN environment variable contains trailing whitespace, such as a newline character. This is common when the token is sourced from a CI secret or file.

The requests library rejects header values containing reserved characters like newlines. Previously, the get_token_header and get_token_header_or_fail functions in codecov_cli/helpers/request.py would interpolate the token directly into the Authorization header without sanitization.

This fix modifies both functions to call .strip() on the token before constructing the header. This ensures that any leading or trailing whitespace is removed, preventing the InvalidHeader error. Since Codecov tokens are typically UUIDs and do not legitimately contain surrounding whitespace, this change does not compromise security or functionality.

Fixes CLI-1R

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