New-MgEntitlementManagementAccessPackageAssignmentRequest ensure DateTime.Kind of StartDateTime is Utc #989
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the Identity.Governance custom beta cmdlet, the cmdlet was setting the
StartDateTimeproperty by supplying a string value in UTC format. However, issue #901 highlighted that this would override the caller's start date time, and also the generated output had the incorrect time zone. So this PR addresses two problems.First, for background, the underlying autogeneratied code contains a C#
DateTimerather thanDateTimeOffsetfor Edm.DateTimeOffset., Furthermore, the converters to JSON of aDateTimewould use itsToString()method with a DateTimeFormat string ending inK(see for example 'date-time.ts' in autorest powershell for an example of that format string). Unfortunately, the semantics of the K format specifier is that the output string's time zone style varies depending on theKindvalue inside theDateTime. So when a caller, in PSh, sets aDateTimeof a .NET object from a string, it is not safe to assume the automatic conversion PowerShell does from a customer's string results in UTC even if the string looks like it could be UTC.. This issue is not specific to the identity.governance module; the problem can occur elsewhere in msgraph-sdk-powershell, wherever a customer sets aDateTimefrom a string and then thatDateTimeis serialized into (for example) a GET filter parameter, or a POST, PUT or PATCH request payload. When theDateTimehas aKindthat is set toUnspecified, meaning that theDateTimeparser earlier could not reliably guarantee that the Date and time the customer had supplied was in a UTC format, then the serialized JSON value fromtoJSON()is not valid OData because it is missing a time zone indicator, and that causes wierd errors to be returned by the Graph services. And if theKindof theDateTimebeing serialized isLocal, then the resulting JSON is not meeting the requirements of the Graph API, which state that time strings are in UTC, as waw seen in #901.This change removes setting the start date explicitly, and instead adds an check on the customer's supplied value, to force the
Kindto always beUtcif theParsemethod did not detectUtc.