Update Event recorder to not parse % format characters in error message#838
Merged
negz merged 1 commit intocrossplane:mainfrom May 21, 2025
Merged
Update Event recorder to not parse % format characters in error message#838negz merged 1 commit intocrossplane:mainfrom
negz merged 1 commit intocrossplane:mainfrom
Conversation
*Eventf takes a format string. This change passes "%s" as the format string and then the unsanitized string as an argument. Fixes crossplane#837 Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>
negz
reviewed
May 19, 2025
| // Event records the supplied event. | ||
| func (r *APIRecorder) Event(obj runtime.Object, e Event) { | ||
| r.kube.AnnotatedEventf(obj, r.annotations, string(e.Type), string(e.Reason), e.Message) | ||
| r.kube.AnnotatedEventf(obj, r.annotations, string(e.Type), string(e.Reason), "%s", e.Message) |
Member
There was a problem hiding this comment.
Is there an AnnotatedEvent (non-f) variant we could use instead?
Contributor
Author
There was a problem hiding this comment.
Not with Annotated, just Event without f, as far as I could see: https://github.com/kubernetes/client-go/blob/master/tools/record/event.go#L92-L111
negz
approved these changes
May 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
*Eventf takes a format string. This change passes "%s" as the format string
and then the unsanitized string as an argument.
Fixes #837
Description of your changes
I have:
Runearthly +reviewableto ensure this PR is ready for review.Added or updated unit tests.Linked a PR or a docs tracking issue to document this change.Addedbackport release-x.ylabels to auto-backport this PR.Need help with this checklist? See the cheat sheet.