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

RegistryManager.GetTwinAsync throws exceptions #1122

Closed
hanabi1224 opened this issue Nov 15, 2019 · 3 comments · Fixed by #1175
Closed

RegistryManager.GetTwinAsync throws exceptions #1122

hanabi1224 opened this issue Nov 15, 2019 · 3 comments · Fixed by #1175
Assignees
Labels
investigation-required Requires further investigation to root cause this.

Comments

@hanabi1224
Copy link

Message:
Microsoft.Azure.Devices.Common.Exceptions.IotHubException : Error converting value 1/1/0001 12:00:00 AM +00:00 to type 'System.DateTime'. Path 'statusUpdateTime', line 1, position 142.
----> Newtonsoft.Json.JsonSerializationException : Error converting value 1/1/0001 12:00:00 AM +00:00 to type 'System.DateTime'. Path 'statusUpdateTime', line 1, position 142.
----> System.InvalidCastException : Object must implement IConvertible.
Stack Trace:
HttpClientHelper.ExecuteAsync(HttpClient httpClient, HttpMethod httpMethod, Uri requestUri, Func3 modifyRequestMessageAsync, Func2 isMappedToException, Func3 processResponseMessageAsync, IDictionary2 errorMappingOverrides, CancellationToken cancellationToken)
HttpClientHelper.GetAsync[T](Uri requestUri, TimeSpan operationTimeout, IDictionary2 errorMappingOverrides, IDictionary2 customHeaders, Boolean throwIfNotFound, CancellationToken cancellationToken)
AzureIoTUtils.GetTwinAsync(String deviceId) line 41
AzureIoTUtilsTests.TestGetTwinAsync(String deviceId) line 33
GenericAdapter1.BlockUntilCompleted() NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaitable) AsyncToSyncAdapter.Await(Func1 invoke)
TestMethodCommand.RunTestMethod(TestExecutionContext context)
TestMethodCommand.Execute(TestExecutionContext context)
SimpleWorkItem.PerformWork()
--JsonSerializationException
JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
JsonSerializerProxy.DeserializeInternal(JsonReader reader, Type objectType)
JsonSerializer.Deserialize(JsonReader reader, Type objectType)
JsonSerializer.Deserialize[T](JsonReader reader)
TwinJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
JsonSerializer.Deserialize(JsonReader reader, Type objectType)
JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
JsonConvert.DeserializeObject[T](String value)
HttpClientHelper.ReadResponseMessageAsync[T](HttpResponseMessage message, CancellationToken token)
<b__9>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
HttpClientHelper.ExecuteAsync(HttpClient httpClient, HttpMethod httpMethod, Uri requestUri, Func3 modifyRequestMessageAsync, Func2 isMappedToException, Func3 processResponseMessageAsync, IDictionary2 errorMappingOverrides, CancellationToken cancellationToken)
--InvalidCastException
Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)

@abhipsaMisra
Copy link
Member

Thank you for reporting this. Could you also share the scenario and steps to reproduce this issue?

@hanabi1224
Copy link
Author

Just set default JsonSerializerSettings.DateParseHandling to DateParseHandling.DateTimeOffset

@az-iot-builder-01
Copy link
Contributor

@abhipsaMisra, @hanabi1224, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation-required Requires further investigation to root cause this.
Projects
None yet
4 participants