Skip to content

Node.js client throwing an error while API return Plan limit has been reached error #265

@ppinel

Description

@ppinel

Prerequisites

Put an X between the brackets on this line if you have done all of the following:

  • Reproduced the problem or exposed a new need
  • Checked the github existing issues

Description

Hello, An error is thrown when API return Plan limit has been reached

error: TypeError: Cannot read properties of undefined (reading 'ocr')
       at new Document (/workflow/node_modules/.pnpm/mindee@4.9.1/node_modules/mindee/src/parsing/common/document.js:20:33)
       at new PredictResponse (/workflow/node_modules/.pnpm/mindee@4.9.1/node_modules/mindee/src/parsing/common/predictResponse.js:19:25)
       at Client.parse (/workflow/node_modules/.pnpm/mindee@4.9.1/node_modules/mindee/src/client.js:67:16)
       at processTicksAndRejections (node:internal/process/task_queues:95:5)
       at async /workflow/workers/src/activities/mindee/processInvoice.ts:32:20
       at async Activity.execute (/workflow/node_modules/.pnpm/@temporalio+worker@1.9.3/node_modules/@temporalio/worker/src/activity.ts:117:14)
       at async /workflow/node_modules/.pnpm/@temporalio+worker@1.9.3/node_modules/@temporalio/worker/src/activity.ts:144:24
       at async /workflow/node_modules/.pnpm/@temporalio+worker@1.9.3/node_modules/@temporalio/worker/src/worker.ts:974:24 

I initilaized the Mindee client to not throw, instead return an error.

const inputSource = mindee.docFromStream(stream, filename);
const result = await mindee.parse(product.InvoiceV4, inputSource);

Steps to Reproduce

  1. Have an account with API usage limit reached
  2. Initialise the client api to not throw (I don't if this one change anything to the behaviour)
  3. Call the API to process an invoice

Expected behavior:

Client should not through, instead return an error with proper error code as mentioned in documentation.

Actual behavior:

An error is thrown saying : TypeError: Cannot read properties of undefined (reading 'ocr')
It shouldn't be trying to process the API response while having an error returned.

Reproduces how often:

Every time

Versions

npm list | grep mindee
├── mindee@4.9.1 -> ./../node_modules/.pnpm/mindee@4.9.1/node_modules/mindee

Testing on Mac OS 14.1.1
Using Node.js v20.9.0

Additional Information

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions