AzureContentUnderstanding: ExtractAsync throws when a chart figure's content is a JSON string

Aberta Para iniciantes
#86 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
75/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
csharp
Domínio
backend

Direção de pesquisa

Comece com Directory.Packages.props e DocumentExtraction/src/AzureContentUnderstanding/ContentUnderstandingExtractionClient.cs e, em seguida, revise a correção do SDK vinculada e o teste de reprodução de AzureContentUnderstanding.UnitTests descrito na issue. Quando Azure.AI.ContentUnderstanding lançar a correção, atualize a versão do pacote e adicione um teste em que content de uma figura de gráfico seja uma string JSON; verifique se a extração retorna o documento.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug

The Content Understanding provider fails on documents with some charts. The cause is a defect in Azure.AI.ContentUnderstanding 1.1.0, the version in Directory.Packages.props: Azure/azure-sdk-for-net#57370. The fix is proposed in Azure/azure-sdk-for-net#64660.

What happens

For some charts the service returns the content of a chart figure, the Chart.js config, as an escaped JSON string instead of an object. The service team confirmed it in Azure/azure-sdk-for-net#57370. The SDK cannot deserialize the result, so operation.Value in ContentUnderstandingExtractionClient.ExtractAsync throws, and no part of the document is returned:

System.InvalidOperationException: The requested operation requires an element of type 'Object', but the target element has type 'String'.
   at System.Text.Json.JsonElement.EnumerateObject()
   at Azure.AI.ContentUnderstanding.DocumentChartFigure.DeserializeDocumentChartFigure(JsonElement element, ModelReaderWriterOptions options)
   ...
   at Azure.Core.ProtocolOperationHelpers.ConvertOperation`2.get_Value()
   at CommunityToolkit.DocumentExtraction.AzureContentUnderstanding.ContentUnderstandingExtractionClient.ExtractAsync(Stream document, String identifier, String mediaType, DocumentExtractionOptions options, CancellationToken cancellationToken)

Only analyzers that return chart figures can hit it, such as prebuilt-documentSearch: in our run, its chart came back as an object. The default, prebuilt-document, returns no figures.

How it was checked

A test in AzureContentUnderstanding.UnitTests replays a real prebuilt-layout result whose figure is changed into a chart figure, as prebuilt-documentSearch returns it. The provider sources are the ones on main, on .NET 10.

  • With 1.1.0 and the chart content as an object, ExtractAsync returns the document.
  • With 1.1.0 and the chart content as a string, ExtractAsync throws the exception above.
  • With a build of the SDK that has the fix, both cases pass, and so do the other 136 tests of the project.

In the toolkit

When a release of Azure.AI.ContentUnderstanding includes the fix, the version in Directory.Packages.props can move to it, with a test on a chart figure whose content is a string.

Linguagem predominante
C#
Estrelas
15
Forks
9
Merge médio
1d 19h
PRs com merge (30d)
14

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de CommunityToolkit/AI

Todas as issues de CommunityToolkit/AI

Issues semelhantes

Mais issues de C#

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.