-
Notifications
You must be signed in to change notification settings - Fork 18k
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
encoding/json: stricter time parsing with Go 1.20 #57897
Comments
note time parsing for RFC3339 became stricter in 1.20 |
see #54568 |
OK. I tried to simplify to:
But it passed, so I couldn't narrow it further. So this is a breaking change in Go 1.20. I have no idea whether there is 0 or a billion invalid time fields in the wild. This is a bad change with things potentially breaking just because of a Go upgrade. Is there a compatibility flag we can set? The added 'strictness' adds no value, but adds a huge load of risk of random breakage. |
IMO this should be an option on Edit: As an example our server offers remote queries on user uploaded data. As such we don't control the input. When an upgrade suddenly starts returning errors on previously working data, that is a problem. And there are hundreds of S3 compatible clients out there. While I don't know, upgrading to this functionality may suddenly break some. It doesn't seem like a good response to say "well, technically the JSON your program writes is invalid", when it has worked previously without problems. |
cc @dsnet |
I agree that this should be an option instead. |
The draft go1.20 release notes indicate "The Time.MarshalJSON and Time.UnmarshalJSON methods are now more strict about adherence to RFC 3339." but do not give any details... I'm surprised to see MarshalJSON mentioned as being more strict... does this mean that in previous go versions, MarshalJSON could produce content that go1.20 UnmarshalJSON will reject? Can we get more details about the changes, and interoperability with previous go versions? Making MarshalJSON adhere to RFC3339 seems like it could be a positive step. Changing UnmarshalJSON to reject data it previously accepted seems questionable to me and I'd be interested to know the rationale. If the change is still determined to be necessary, this seems like a good chance to apply the compatibility principles outlined in #56986. |
@liggitt It is not my understanding that Go at any point has output these values. My concern is however that there may be persisted data or outputs from other languages that have this inconsistency and relies on these values being accepted. |
Agreed. At the very least I think we should have a |
CC @dsnet |
Thanks for the report. Let's close this as a duplicate of #54580 to keep discussion in one place. |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry for the double CC. |
My mistake, meant to reference #54580 |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Go 1.19.5 works, Go 1.20RC3 is broken.
What operating system and processor architecture are you using (
go env
)?go env
OutputBut was reported on linux/amd64 which should be used for repro
What did you do?
Run the following test:
What did you expect to see?
Same result as Go 1.19.5:
What did you see instead?
I will try to see if I can identify the underlying difference. This is not a simpletime.Parse
issue, but seems to be related to functionality insidegithub.com/json-iterator/go
. It reproduces on multiple platforms.EDIT: Reproducer changed to stdlib json
The text was updated successfully, but these errors were encountered: