question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUERY] Failed to de-serialize JSON on date `2020-02-18T10:14:43.06`

See original GitHub issue

Query/Question

De-serialize JSON failed on incorrect date e.g. 2020-02-18T10:14:43.06. (lack Z at last char)

Error message

com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.OffsetDateTime` from String "2020-02-18T10:14:43.06": Failed to deserialize java.time.OffsetDateTime: (java.time.format.DateTimeParseException) Text '2020-02-18T10:14:43.06' could not be parsed at index 22

This probably is web service problem, but I don’t think server will fix.

It happens for multiple mgmt services (include web, sql, etc.).

Let me know whether azure core would adapt for this.


Sample request

PUT https://management.azure.com/subscriptions/###/resourcegroups/javacsmrga8d720064/Microsoft.Web/sites/java-webapp-484058?api-version=2019-08-01

Sample response

{"id":"/subscriptions/ec0aa5f7-9e78-40c9-85cd-535c6305b380/resourceGroups/javacsmrga8d720064/providers/Microsoft.Web/sites/java-webapp-484058","name":"java-webapp-484058","type":"Microsoft.Web/sites","kind":"app","location":"westus","tags":{},"properties":{"name":"java-webapp-484058","state":"Running","hostNames":["java-webapp-484058.azurewebsites.net"],"webSpace":"javacsmrga8d720064-WestUSwebspace","selfLink":"https://waws-prod-bay-115.api.azurewebsites.windows.net:454/subscriptions/ec0aa5f7-9e78-40c9-85cd-535c6305b380/webspaces/javacsmrga8d720064-WestUSwebspace/sites/java-webapp-484058","repositorySiteName":"java-webapp-484058","owner":null,"usageState":"Normal","enabled":true,"adminEnabled":true,"enabledHostNames":["java-webapp-484058.azurewebsites.net","java-webapp-484058.scm.azurewebsites.net"],"siteProperties":{"metadata":null,"properties":[{"name":"LinuxFxVersion","value":""},{"name":"WindowsFxVersion","value":null}],"appSettings":null},"availabilityState":"Normal","sslCertificates":null,"csrs":[],"cers":null,"siteMode":null,"hostNameSslStates":[{"name":"java-webapp-484058.azurewebsites.net","sslState":"Disabled","ipBasedSslResult":null,"virtualIP":null,"thumbprint":null,"toUpdate":null,"toUpdateIpBasedSsl":null,"ipBasedSslState":"NotConfigured","hostType":"Standard"},{"name":"java-webapp-484058.scm.azurewebsites.net","sslState":"Disabled","ipBasedSslResult":null,"virtualIP":null,"thumbprint":null,"toUpdate":null,"toUpdateIpBasedSsl":null,"ipBasedSslState":"NotConfigured","hostType":"Repository"}],"computeMode":null,"serverFarm":null,"serverFarmId":"/subscriptions/ec0aa5f7-9e78-40c9-85cd-535c6305b380/resourceGroups/javacsmrga8d720064/providers/Microsoft.Web/serverfarms/java-asp-c9a952873","reserved":false,"isXenon":false,"hyperV":false,"lastModifiedTimeUtc":"2020-02-18T08:42:27.8166667","storageRecoveryDefaultState":"Running","contentAvailabilityState":"Normal","runtimeAvailabilityState":"Normal","siteConfig":null,"deploymentId":"java-webapp-484058","trafficManagerHostNames":null,"sku":"Basic","scmSiteAlsoStopped":false,"targetSwapSlot":null,"hostingEnvironment":null,"hostingEnvironmentProfile":null,"clientAffinityEnabled":true,"clientCertEnabled":false,"clientCertExclusionPaths":null,"hostNamesDisabled":false,"domainVerificationIdentifiers":null,"customDomainVerificationId":"2D9D2C35841FDE47EE3955E78F943C99EF6D4FB99D295897A5BC167F8837561D","kind":"app","inboundIpAddress":"40.112.192.69","possibleInboundIpAddresses":"40.112.192.69","outboundIpAddresses":"40.112.192.69,40.112.196.57,40.112.198.128,40.78.3.182,40.78.2.143","possibleOutboundIpAddresses":"40.112.192.69,40.112.196.57,40.112.198.128,40.78.3.182,40.78.2.143,40.112.193.168,40.78.1.240,40.78.1.3","containerSize":0,"dailyMemoryTimeQuota":0,"suspendedTill":null,"siteDisabledReason":0,"functionExecutionUnitsCache":null,"maxNumberOfWorkers":null,"homeStamp":"waws-prod-bay-115","cloningInfo":null,"hostingEnvironmentId":null,"tags":{},"resourceGroup":"javacsmrga8d720064","defaultHostName":"java-webapp-484058.azurewebsites.net","slotSwapStatus":null,"httpsOnly":false,"redundancyMode":"None","inProgressOperationId":null,"geoDistributions":null,"privateEndpointConnections":null,"buildVersion":null,"targetBuildVersion":null}}

Why is this not a Bug or a feature Request? A clear explanation of why is this not a bug or a feature request?

More likely a service bug. I need to know whether core would adapt it.

Setup (please complete the following information if applicable):

  • OS: Windows
  • IDE : IntelliJ
  • Version of the Library used: core 1.2.0

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Query Added
  • Setup information Added

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
weidongxu-microsoftcommented, Feb 19, 2020

I will try unblock myself by this

    static class DateTimeDeserializer extends JsonDeserializer<OffsetDateTime> {

        public static SimpleModule getModule() {
            SimpleModule module = new SimpleModule();
            module.addDeserializer(OffsetDateTime.class, new DateTimeDeserializer());
            return module;
        }

        @Override
        public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
            String string = jsonParser.getText();
            TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest(string, OffsetDateTime::from, LocalDateTime::from);
            if (temporal.query(TemporalQueries.offset()) == null) {
                return LocalDateTime.from(temporal).atOffset(ZoneOffset.UTC);
            } else {
                return OffsetDateTime.from(temporal);
            }
        }
    }

        serializerAdapter.serializer().registerModule(DateTimeDeserializer.getModule());
0reactions
weidongxu-microsoftcommented, Apr 21, 2020

Reopen it since @JonathanGiles requires us to remove serializer package in core-management. Hence it had to be mitigated in core.

Tasks for management team: • Remove CloudException type from azure-core-management • Move CloudError into .exception package • Supply build instructions • Move PollerFactory out of implementation package and into polling • Remove serializer package

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to deserialize JSON - OutSystems
I am new at OutSystems and I'm trying to deserialize the content which is an attribute from an entity. However it ends in...
Read more >
Cannot deserialize the JSON array (e.g. [1,2,3]) into type ...
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or...
Read more >
JSON: Cannot deserialize instance of date from ...
Three problems here: (a) Date receiving DateTime value. The value should be "YYYY-MM-DD" only. (b) Decimal receiving String value.
Read more >
How to allow some kinds of invalid JSON with System.Text.Json
Learn how to allow comments, trailing commas, and quoted numbers while serializing to and deserializing from JSON in .NET.
Read more >
MySQL 8.0 Reference Manual :: 11.5 The JSON Data Type
Attempting to insert a value into a JSON column succeeds if the value is a valid JSON value, but fails if it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found