-
Notifications
You must be signed in to change notification settings - Fork 18k
log/slog: JSONHandler generates invalid JSON with empty Attr #62152
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
Comments
CC @jba. |
Change https://go.dev/cl/521135 mentions this issue: |
This is a bug and it can occur in scenarios where users try to replace some attributes in embedded groups with empty strings. I believe these cases could be common for users. |
@gopherbot please consider this for backport to 1.21, it could be a common case and has no workaround. |
Backport issue(s) opened: #62256 (for 1.21). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
I don't think this requires a backport. It's probably very rare, and you can work around it by just not removing every attr (or adding a dummy one, if you have to remove them all for some security reason). |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?This also reproduces on the go playground.
go env
OutputWhat did you do?
I executed this code in a main function. This can also be reproduced in the go playground: https://go.dev/play/p/i7VtMtNK4eV
What did you expect to see?
The program run successfully without an error.
What did you see instead?
The program panicked with the following error when json unmarshal happened.
The text was updated successfully, but these errors were encountered: