Closed MichalChotvac closed 9 months ago
Exactly same exception here when i am trying to download a file:
graphClient.drives().byDriveId("XXXXXXXXXXXXX") .items().byDriveItemId("root:/MediaMeta.xml").content().get()
Failure happens during deserialization of the innerError
's date
property. The API returns a date time string without the offset e.g. "2024-02-12T19:47:39" but our OpenAPI spec expects a DateTime with an offset which maps to the SDK expecting DateTimeOffset objects. The parsing failure is valid.
.NET's DateTimeOffset implementation seems to handle this case by defaulting to using the UTC timezone. Java's fails.
@baywet @andrueastman might this be an issue during our metadata conversion?
Kiota maps the format: date-time
to DateTimeOffset which downstream languages change in the refiners. Which looks like the right thing to do.
However, the pattern string/regex suggest that the offset is optional despite the OpenApi spec defining the offset as mandatory for date-time
. This is probably because odata ABNF has the the offset as optional.
date:
pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$'
type: string
description: Date when the error occured.
format: date-time
nullable: true
Ideally,
format: date-time
for Edm.DateTimeOffset
types and generate only a string pattern.DateTimeOffset
type(since the offset can be there)However, since it would it still end up being to the DateTimeOffset
type, I think we probably would end need to end up just updating the deserialization library to allow for the scenario and default to UTC.
Thank for the clarity @andrueastman! I agree that we can add a default UTC offset if none is present in the API response before deserializing to a DateTimeOffset.
Exactly what Andrew said. Just adding a bit of tolerance when parsing things here should be enough. It's interesting that Java is the only language with which we've faced that to date though, but it makes sense since Java "is more of a purist language".
Version 6.2.1
contains this fix.
Expected behavior
The message of the ApiException will contain a more specific error message based on the OdataError returned from the API.
Documentation
Actual behavior
When trying to get user who does not exist in Graph java.time.format.DateTimeParseException is thrown
Steps to reproduce the behavior
Result:
Library: