Skip to content

Trim credentials read from the Provider secret - #1446

Merged
matheuscscp merged 1 commit into
fluxcd:mainfrom
gecube:trim-secret-credentials
Dec 2, 2026
Merged

matheuscscp merged 1 commit into
fluxcd:mainfrom
gecube:trim-secret-credentials

Conversation

@gecube

@gecube gecube commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #1445

Since #1146 the token and basic auth credentials are read with secrets.AuthMethodsFromSecret and passed to the notifiers untrimmed, so the trimming added in #789 (for #760) no longer applies to them. A token with a trailing newline breaks the Authorization header (net/http: invalid header field value for "Authorization"); a username/password with whitespace is sent as is.

This trims them again in extractAuthFromSecret. The new test fails on main for both cases and passes with the change. make tidy fmt vet && make test pass locally.

A reproduction with kind against v1.6.0, v1.7.0 and v1.10.1 is in #1445.

I used Claude Code to investigate the regression and draft the change and the test; I reviewed and tested it.

Since the token, username and password are read with
secrets.AuthMethodsFromSecret, they are passed to the notifiers as
stored in the Secret. A token with a trailing newline, as produced by
`echo $TOKEN | base64` or `kubectl create secret --from-file`, makes
Go reject the Authorization header and every notification fails with
"invalid header field value". Basic auth credentials are sent with the
whitespace included.

Trim them again, as extractAuthFromSecret did before the switch.

Assisted-by: claude-code/claude-opus-5-5
Signed-off-by: George Gaál <gb12335@gmail.com>

@matheuscscp matheuscscp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matheuscscp
matheuscscp merged commit c7535c8 into fluxcd:main Dec 2, 2026
5 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.

Provider secret token is not trimmed since v1.7.0: a trailing newline breaks the Authorization header

2 participants