Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
ppinel opened this issue Apr 5, 2024 · 2 comments
Open
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@ppinel
Copy link

ppinel commented Apr 5, 2024

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/[email protected]/node_modules/mindee/src/parsing/common/document.js:20:33)
       at new PredictResponse (/workflow/node_modules/.pnpm/[email protected]/node_modules/mindee/src/parsing/common/predictResponse.js:19:25)
       at Client.parse (/workflow/node_modules/.pnpm/[email protected]/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/@[email protected]/node_modules/@temporalio/worker/src/activity.ts:117:14)
       at async /workflow/node_modules/.pnpm/@[email protected]/node_modules/@temporalio/worker/src/activity.ts:144:24
       at async /workflow/node_modules/.pnpm/@[email protected]/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
├── [email protected] -> ./../node_modules/.pnpm/[email protected]/node_modules/mindee

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

Additional Information

@ianardee ianardee added the bug Something isn't working label Apr 5, 2024
@sebastianMindee sebastianMindee added the wontfix This will not be worked on label Apr 10, 2024
@sebastianMindee
Copy link
Collaborator

This issue arises from the implementation of throwOnError, which is currently malfunctioning due to significant changes made since its initial implementation. It is planned to undergo substantial refactoring in the future and will be deprecated in the next release. In the meantime, I advise all users attempting to utilize the throwOnError parameter to instead handle the relevant exceptions using catch.

@sebastianMindee sebastianMindee closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2024
@sebastianMindee
Copy link
Collaborator

Update: while not addressing the throwOnError problem directly, some error displays similar to this one should be fixed in #267.

Also, for the sake of visibility I will keep this opened until we fully fix the throwOnError incompatibility.

@sebastianMindee sebastianMindee removed the wontfix This will not be worked on label Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants