Skip to content

DocumentAnalysisClient throws a RestError #29826

Open

Description

  • Package Name: @azure/ai-form-recognizer
  • Package Version: 5.0.0
  • Operating system: Windows
  • nodejs
    • version: v20.12.1
  • browser
    • name/version: irrelevant / no browser needed
  • typescript
    • version: 5.4.5
  • Is the bug related to documentation in

Describe the bug
The DocumentAnalysisClient throws a RestError exception when attempting to analyze a document from a URL using the beginAnalyzeDocumentFromUrl method. The error occurs during the deserialization of the response body.

To Reproduce
Steps to reproduce the behavior:

  1. Initialize a new instance of DocumentAnalysisClient.
  2. Call the beginAnalyzeDocumentFromUrl method with 'prebuilt-layout' and a valid blobUri.
  3. Observe the exception thrown during execution.

Sample code:

const _client = new DocumentAnalysisClient();
const poller = await _client.beginAnalyzeDocumentFromUrl('prebuilt-layout', "https://example.com/sample.pdf");

Expected behavior
Return a poller.

Error

System.Private.CoreLib: Exception while executing function: Functions.ExtractLayoutFunction. 
System.Private.CoreLib: Result: Failure
Exception:
Stack: RestError
    at handleErrorResponse (C:\...\node_modules\@azure\core-client\dist\commonjs\deserializationPolicy.js:148:19)
    at deserializeResponseBody (C:\...\node_modules\@azure\core-client\dist\commonjs\deserializationPolicy.js:83:45)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Response returned

{
  "status": 400,
  "headers": {
    "content-length": "0",
    "apim-request-id": "...",
    "strict-transport-security": "max-age=31536000; includeSubDomains; preload",
    "x-content-type-options": "nosniff",
    "date": "Tue, 28 May 2024 13:20:36 GMT"
  },
  "request": {
    "url": "https://westeurope.api.cognitive.microsoft.com/formrecognizer/documentModels/prebuilt-layout:analyze?api-version=2023-07-31",
    "body": "{\"urlSource\":\"https://example.com/sample.pdf\"}",
    "headers": {
      "content-type": "application/json",
      "accept": "application/json",
      "accept-encoding": "gzip,deflate",
      "user-agent": "azsdk-js-ai-form-recognizer/5.0.0 core-rest-pipeline/1.16.0 Node/20.12.1 OS/(x64-Windows_NT-10.0.22621)",
      "x-ms-client-request-id": "...",
      "authorization": "Bearer ...",
      "content-length": "144"
    },
    "method": "POST",
    "timeout": 0,
    "disableKeepAlive": false,
    "streamResponseStatusCodes": {},
    "withCredentials": false,
    "tracingOptions": {
      "tracingContext": {
        "_contextMap": {}
      }
    },
    "requestId": "...",
    "allowInsecureConnection": false,
    "enableBrowserStreams": false
  },
  "bodyAsText": ""
}

Additional context
Runs in an Azure Function locally, connecting to Azure Document Intelligence Storage remotely. The error appears to be related to the deserialization policy within the @azure/core-client module. It may indicate an issue with the response body not conforming to the expected format or an unexpected server response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.Cognitive - Form RecognizerService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions