-
Notifications
You must be signed in to change notification settings - Fork 130
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
Azure-Core: If no timezone information is present in string, assume local time and convert to UTC #5076
Conversation
…ocal time and convert to UTC
Thank you for your contribution @janbernloehr! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @janbernloehr!
Current behavior existed since the beginning, and it is hard to tell right away, how, if, and where it would affect us or our customers.
This looks like a breaking change - previously a user would parse 2023-10-26T18:18:18
and get UTC value, now they'll get a different value.
FWIW, current behavior is consistent with .NET:
Console.WriteLine(DateTime.Parse("2023-10-26T18:18:18").ToLocalTime()); // When ran in PST time zone, prints "Oct 26, 2023 11:18:18".
I think #5075 should be fixed tactically in the Azure CLI credential - it could be that DateTime::Parse()
gets something like a treatNoTimeZoneAsLocal = false
third parameter, or something like that. And then the AzureCLI credential passes that flag to the TokenCredentialImpl
, and then its token parser uses that flag when parsing the token expiration time.
cc @ahsonkhan
One minor note: RFC 3339 requires a timezone element. Our parser appears to allow RFC 3339 elements without a timezone element, but it is a non-standard extension. We certainly should never generate such a time. |
It could probably also be fixed in az cli by creating a string complying with RFC 3339 these might be related: |
Thank you, @janbernloehr - these are great links and the context, I even left one possible idea in the first one. |
Hi @janbernloehr, @antkmsft, I am the owner of Azure CLI command
|
Thank you @jiasli - the Azure SDK for C++'s current implementation would successfully be able to parse Unix timestamp ( azure-sdk-for-cpp/sdk/identity/azure-identity/src/token_credential_impl.cpp Lines 292 to 327 in 50c1851
AzureSDK for .NET would break - https://github.com/Azure/azure-sdk-for-net/blob/ba1e6df24131bfc88619c12c4c592933f78fcd18/sdk/identity/Azure.Identity/src/Credentials/AzureCliCredential.cs#L236, we should communicate this to them. Possibly, some other SDKs may get broken by this change as well. cc @ahsonkhan @schaabs @scottaddie @azure-sdk-write-identity |
@jiasli Which version number will contain this new |
@scottaddie, I have updated my comment #5076 (comment) to include that information. |
@antkmsft, I provided more information in Azure/azure-cli#27476. We are not going to make any change on |
#5179 would treat datetimes it gets from azcli as local time, if no time zone information is present. |
Fixed in #5179 |
This PR proposes a fix for #5075. There might be side-effects, though. Feedback welcome.
Pull Request Checklist
Please leverage this checklist as a reminder to address commonly occurring feedback when submitting a pull request to make sure your PR can be reviewed quickly:
See the detailed list in the contributing guide.