Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect use of format strings with the conditions package. #1025

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

octo
Copy link
Contributor

@octo octo commented Jul 12, 2024

The Mark… functions in the conditions package accept a format string and (optional) arguments, just like fmt.Printf and friends.

In many places, the code passed an error message as the format string, causing it to be interpreted as a format string by the fmt package. This leads to issues when the message contains percent signs, e.g. URL-encoded values.

This PR adds a format string and shortens err.Error() to err, which yields the same output.

This change is identical in principle to fluxcd/source-controller#1529.

Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @octo

@stefanprodan stefanprodan added the backport:release/v1.0.x To be backported to release/v1.0.x label Jul 12, 2024
@octo
Copy link
Contributor Author

octo commented Jul 12, 2024

Thanks for the quick reviews @stefanprodan! 🎉

@stefanprodan
Copy link
Member

@octo please fix:

internal/reconcile/atomic_release.go:201:6: github.com/fluxcd/pkg/runtime/conditions.MarkStalled call needs 1 arg but has 2 args

@octo
Copy link
Contributor Author

octo commented Jul 12, 2024

@octo please fix:

internal/reconcile/atomic_release.go:201:6: github.com/fluxcd/pkg/runtime/conditions.MarkStalled call needs 1 arg but has 2 args

✅ done

The `Mark…` functions in the `conditions` package accept a format string and
(optional) arguments, just like `fmt.Printf` and friends.

In many places, the code passed an error message as the format string, causing
it to be interpreted as a format string by the `fmt` package. This leads to
issues when the message contains percent signs, e.g. URL-encoded values.

This PR adds a format string and shortens `err.Error()` to `err`, which yields
the same output.

This change is identical in principle to
fluxcd/source-controller#1529.

Signed-off-by: Florian Forster <fforster@gitlab.com>
@stefanprodan stefanprodan merged commit 70dadf7 into fluxcd:main Jul 12, 2024
6 checks passed
@fluxcdbot
Copy link
Member

Successfully created backport PR for release/v1.0.x:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:release/v1.0.x To be backported to release/v1.0.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants