Search code examples
azure-cognitive-servicesazure-form-recognizer

Deserializing Issue in Azure Cognitive Services Form Recognizer client library for .NET - Version 3.1.0-beta.4


I have a labeled model with a "label table". This model works well with the latest REST API, but not with the .NET Client Library 3.1.0-beta.4. In cases where the model predicts an empty cell in the "label table", an InvalidOperationException occurs when the library deserializes the result.

Exception Details

System.InvalidOperationException: The requested operation requires an element of type 'Object', but the target element has type 'Null'. at System.Text.Json.JsonElement.EnumerateObject() at Azure.AI.FormRecognizer.Models.FieldValue_internal.DeserializeFieldValue_internal(JsonElement element) at Azure.AI.FormRecognizer.Models.FieldValue_internal.DeserializeFieldValue_internal(JsonElement element) 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) at Azure.Core.OperationHelpers.DefaultWaitForCompletionAsync[TResult](Operation1 operation, TimeSpan pollingInterval, CancellationToken cancellationToken) at System.Threading.Tasks.ValueTask1.get_Result() at KKELBelegAnalyzer.BelegAnalyzer.AnalyzeBeleg(Stream streamInput)


Solution

  • For those with the same problem, this will be fixed on the next beta release in May.
    See the GitHub issue OP submitted for more details.