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

KVListFormat shadow's the Key if It is not a valid string #331

Closed
harshanarayana opened this issue Jun 18, 2022 · 1 comment · Fixed by #332
Closed

KVListFormat shadow's the Key if It is not a valid string #331

harshanarayana opened this issue Jun 18, 2022 · 1 comment · Fixed by #332
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@harshanarayana
Copy link

/kind bug

What steps did you take and what happened:
While trying to take a stab at #275 I noticed that there is a lingering issue in the KVListFormat function in terms of how it processes the keys

if k, ok := k.(string); ok {
// Avoid one allocation when the key is a string, which
// normally it should be.
b.WriteString(k)
} else {
b.WriteString(fmt.Sprintf("%s", k))
}

In case if the key passed to the KVListFormat is not of string type, this ends up consuming the key and only printing the value.

What did you expect to happen:
Based on the current comment/code, the expectation is that it will log the struct using fmt.Sprintf("%s", k) however, this is not working due to variable getting shadow'ed.

Anything else you would like to add:
NA

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 18, 2022
@harshanarayana
Copy link
Author

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants