azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

[BUG] The requested operation requires an element of type 'Number', but the target element has type 'String'.

Open waynebrantley opened this issue 2 years ago • 2 comments

Library name and version

Azure.AI.FormRecognizer Version 3.1.1

Describe the bug

Calling UpdateStatysAsync crashes on json deserialization

In general this works - for a certain document we tried it crashes.

Expected behavior

Should not crash deserializing the result from Azure Api.

Actual behavior

The following exception is thrown.

Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: WaitOnOcrCompletion
 ---> System.InvalidOperationException: The requested operation requires an element of type 'Number', but the target element has type 'String'.
   at System.Text.Json.JsonDocument.TryGetValue(Int32 index, Single& value)
   at System.Text.Json.JsonElement.GetSingle()
   at Azure.AI.FormRecognizer.Models.FieldValue_internal.DeserializeFieldValue_internal(JsonElement element)
   at Azure.AI.FormRecognizer.Models.DocumentResult.DeserializeDocumentResult(JsonElement element)
   at Azure.AI.FormRecognizer.Models.AnalyzeResult.DeserializeAnalyzeResult(JsonElement element)
   at Azure.AI.FormRecognizer.Models.AnalyzeOperationResult.DeserializeAnalyzeOperationResult(JsonElement element)
   at Azure.AI.FormRecognizer.FormRecognizerRestClient.GetAnalyzeFormResultAsync(Guid modelId, Guid resultId, CancellationToken cancellationToken)
   at Azure.AI.FormRecognizer.Models.RecognizeCustomFormsOperation.UpdateStatusAsync(Boolean async, CancellationToken cancellationToken)
   at Azure.AI.FormRecognizer.Models.RecognizeCustomFormsOperation.UpdateStatusAsync(CancellationToken cancellationToken)

Reproduction Steps

string operationId = 22976b9b-45cc-4479-b567-b46eb06e68e4/analyzeresults/fc97d418-1bb2-413d-9029-7886398cf5af var newOp = new RecognizeCustomFormsOperation(operationId, _formRecognizer); await newOp.UpdateStatusAsync();

This only crashes on this one result from Azure. (started today).

Environment

Azure function 4, dotnet 6

waynebrantley avatar Aug 05 '22 19:08 waynebrantley

Thank you for your feedback. Tagging and routing to the team member best able to assist.

jsquire avatar Aug 05 '22 21:08 jsquire

Hello @waynebrantley,

It seems the operation produced a result that can't be parsed by our SDK, which seems to be a bug. Does the error still happens if you try to start a new operation with the same file?

kinelski avatar Aug 09 '22 20:08 kinelski

We cannot reproduce with the same document. I can tell you the document was blank though. So perhaps the result back from the OCR service is very different if it finds nothing?

waynebrantley avatar Aug 12 '22 21:08 waynebrantley

@waynebrantley are you still blocked on the issue?

pallavit avatar Dec 07 '22 23:12 pallavit

This has not happened with the latest SDK.

waynebrantley avatar Dec 10 '22 19:12 waynebrantley

Hi @waynebrantley. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost avatar Feb 02 '23 19:02 ghost

Marking issue as addressed since neither customer nor us could reproduce it with the latest SDK.

kinelski avatar Feb 02 '23 19:02 kinelski

Hi @waynebrantley, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

ghost avatar Feb 09 '23 22:02 ghost