-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Summary:
My API project is facing a KeyError 'page_id' when using new custom endpoints with the Mindee API. This issue is not present with older endpoints, suggesting a potential problem with the newer custom endpoint configuration or the library's response handling.
Background:
Our application leverages Mindee's OCR capabilities to extract data from PDFs. While older endpoints operate as expected with library version 3.13, the integration with newly created custom endpoints leads to a KeyError, even after updating to version 4.0.1.
Issue Description:
Upon invoking client.parse with product.CustomV1 for new custom endpoints, a KeyError is thrown, indicating the absence of 'page_id' in the parsed results. This exception is traced back to the construction of ListFieldV1 within the Mindee library.
Logs:
Traceback (most recent call last): File "C:\Users\PC\PycharmProjects\multiCotizadorAPI\utils\mindee\mindee.py", line 30, in analyze_pdf_with_mindee result = mindee_client.parse(product.CustomV1, input_doc, endpoint=custom_endpoint) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\PC\PycharmProjects\multiCotizadorAPI\venv\Lib\site-packages\mindee\client.py", line 114, in parse return self._make_request( ^^^^^^^^^^^^^^^^^^^ File "C:\Users\PC\PycharmProjects\multiCotizadorAPI\venv\Lib\site-packages\mindee\client.py", line 339, in _make_request return PredictResponse(product_class, dict_response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\PC\PycharmProjects\multiCotizadorAPI\venv\Lib\site-packages\mindee\parsing\common\predict_response.py", line 28, in __init__ self.document = Document(prediction_type, raw_response["document"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\PC\PycharmProjects\multiCotizadorAPI\venv\Lib\site-packages\mindee\parsing\common\document.py", line 47, in __init__ self.inference = prediction_type(raw_response["inference"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\PC\PycharmProjects\multiCotizadorAPI\venv\Lib\site-packages\mindee\product\custom\custom_v1.py", line 27, in __init__ self.prediction = CustomV1Document(raw_prediction["prediction"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\PC\PycharmProjects\multiCotizadorAPI\venv\Lib\site-packages\mindee\product\custom\custom_v1_document.py", line 29, in __init__ self.fields[field_name] = ListFieldV1(field_contents) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\PC\PycharmProjects\multiCotizadorAPI\venv\Lib\site-packages\mindee\parsing\custom\list.py", line 45, in __init__ self.page_id = raw_prediction["page_id"] ~~~~~~~~~~~~~~^^^^^^^^^^^ KeyError: 'page_id'
Troubleshooting Steps:
- Confirmed operational status of older endpoints.
- Encountered the error upon integrating new custom endpoints.
- Library updated from 3.13 to 4.0.1, with no resolution.
- Adherence to the updated Mindee documentation confirmed.
- Codebase reviewed for discrepancies with custom endpoint usage.
Current Findings:
- The issue is isolated to new custom endpoints.
- The potential misalignment between the library's expectations and the custom endpoint's response.
- The persistent problem post-library update suggests the issue might be beyond the client-side code.
-We request the Mindee team's input on this matter. Could you advise on any known issues with custom endpoint integration or suggest further steps we might take to debug this problem? Any assistance would be greatly appreciated to facilitate a swift resolution.
Thank you for your attention to this matter.