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

[release/8.0] Use invariant culture in CBOR date encoding #92924

Merged
merged 3 commits into from Oct 4, 2023

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 3, 2023

Backport of #92539 to release/8.0

/cc @eiriktsarpalis @filipnavara

Customer Impact

Since it was released in .NET 5, the System.Formats.Cbor NuGet package included built-in methods for serializing and deserializing DateTimeOffset values according to RFC 7049. Unfortunately, the implementations weren't using invariant culture when formatting/parsing DateTimeOffset values. This can result in inconsistent or even incorrect date encodings in machines with cultures using non-Gregorian calendars.

Even though the bug has been present since the release of the library, consensus is that we'd like this to be backported to .NET 8 so that a fixed LTS release becomes available to customers.

Testing

Adding unit testing validating the fix.

Risk

Moderate. While the product fix is small and straightforward, this is a breaking change for users that rely on the existing behavior to deserialize encodings created by earlier versions of the library. We will document this as a breaking change and provide workarounds, however it was deemed that a compatibility switch is not necessary, given that the library is an out-of-band package that can be updated independently of the framework.

@ghost
Copy link

ghost commented Oct 3, 2023

Tagging subscribers to this area: @dotnet/area-system-formats-cbor, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #92539 to release/8.0

/cc @eiriktsarpalis @filipnavara

Customer Impact

Testing

Risk

IMPORTANT: If this backport is for a servicing release, please verify that:

  • The PR target branch is release/X.0-staging, not release/X.0.

  • If the change touches code that ships in a NuGet package, you have added the necessary package authoring and gotten it explicitly reviewed.

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Formats.Cbor

Milestone: -

@eiriktsarpalis eiriktsarpalis added this to the 8.0.0 milestone Oct 3, 2023
@eiriktsarpalis eiriktsarpalis self-assigned this Oct 3, 2023
@danmoseley
Copy link
Member

Is there any reasonable way (egg a relevant analyzer, or grep) to attempt to scan the Cbor code as a whole for any other place culture is assumed? Presumably they would be bugs.

Does changing local culture to a highly bogus custom culture cause any tests to fail?

@eiriktsarpalis eiriktsarpalis changed the title [release/8.0] Use invariant culture for CBOR [release/8.0] Use invariant culture in CBOR date encoding Oct 3, 2023
@eiriktsarpalis eiriktsarpalis added the Servicing-consider Issue for next servicing release review label Oct 3, 2023
@eiriktsarpalis
Copy link
Member

Does changing local culture to a highly bogus custom culture cause any tests to fail?

TL;DR yes, I just pushed changes that incorporate testing to the change as well.

@danmoseley
Copy link
Member

Sorry, I meant does it make any tests fail even after the fix - indicating current culture is being used elsewhere in the code.

Not sure the easiest way to apply a custom (or at least non US) culture to all tests, maybe in a static ctor on some core cbor type?

Just throwing this idea out there.

@eiriktsarpalis
Copy link
Member

Not sure the easiest way to apply a custom (or at least non US) culture to all tests, maybe in a static ctor on some core cbor type?

I think we're using machines configured with non US cultures in some of our CI legs, but guessing none of them have a non-Gregorian calendar which is what triggers the particular issue.

@filipnavara
Copy link
Member

Not sure the easiest way to apply a custom (or at least non US) culture to all tests, maybe in a static ctor on some core cbor type?

That's how the issue was originally discovered. I had my machine set to a really weird culture and I run all the CBOR tests with it. The fix made the remaining tests pass.

@danmoseley
Copy link
Member

danmoseley commented Oct 3, 2023

Ah - we're set then. (And setting the machine culture is easier than code, doh)

Btw do all libs test pass with this culture? In the past I've had to fix tests from time to time because they failed in eg Russia.

@danmoseley
Copy link
Member

Perhaps they were outer loop ones, given the CI coverage mentioned. Although IIRC that is something "not that different" to en-US --maybe es-ES.

@filipnavara
Copy link
Member

Btw do all libs test pass with this culture? In the past I've had to fix tests from time to time because they failed in eg Russia.

I didn't get to test that yet... we totally should do it though. Maybe file an issue so we don't forget to do it?

@artl93
Copy link
Contributor

artl93 commented Oct 3, 2023

@eiriktsarpalis - I am not familiar with CBOR, and I assume this is NOT the case, but is there any stream version indicator that we or a user could rev in reaction to this change so that someone could chose to remain compatible with the old behavior for loading old streams?

@eiriktsarpalis
Copy link
Member

Other than information that users choose to add to their own schema, the CBOR format itself doesn't have any versioning attached to its encoding.

@artl93
Copy link
Contributor

artl93 commented Oct 3, 2023

Approved for me.

@carlossanlop carlossanlop added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Oct 4, 2023
@carlossanlop
Copy link
Member

Approved by Tactics via email.

@carlossanlop carlossanlop merged commit 8a66d7d into release/8.0 Oct 4, 2023
109 of 114 checks passed
@carlossanlop carlossanlop deleted the backport/pr-92539-to-release/8.0 branch October 4, 2023 15:55
@carlossanlop carlossanlop added the needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet label Oct 4, 2023
@carlossanlop
Copy link
Member

Added the needs-breaking-change-doc-created label to ensure we get one for this change.

@eiriktsarpalis
Copy link
Member

It's tracked by #92595 so we can remove it from here.

@eiriktsarpalis eiriktsarpalis removed the needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet label Oct 4, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Nov 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants