Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Enterprise Document OCR failing with FAILED_PRECONDITION

Today we have been getting a lot of errors back from production from google Document OCR with the error response:

{'error': {'code': 400, 'message': 'Precondition check failed.', 'status': 'FAILED_PRECONDITION'}

There is no additional information, and trying the same document again after a few hours worked without error. 

Is the service having issues? It is the first time I see this error in 6 months of using this API.

0 1 162
1 REPLY 1

Hi @exarexa,

Welcome to Google Cloud Community!

The FAILED_PRECONDITION error you're seeing with Google Document OCR typically indicates that the document you're submitting doesn't meet the service's preconditions.

Here are some potential causes and ways to address them:

  1. Document Format and Size:
  • Unsupported Format: Ensure the document is in a supported format (PDF, JPG, PNG, TIFF). Check the Google Cloud Vision API or Document AI documentation for the latest list of supported formats.
  • File Size Limits: The service may have limits on the maximum file size for processing. Refer to the documentation for the current limits.
  • File Corruption: If the document is corrupt, the OCR service may fail. Try opening the file in a different program to check for corruption.
  1. Content and Quality:
  • Low Quality: Blurry, low-resolution images or documents with heavily distorted text can cause issues. Try using a clearer version of the document.
  • Complex Layout: Documents with intricate layouts, multiple columns, or very small text may be harder for OCR to process accurately.
  • Unsupported Languages: The OCR service may not support all languages. Check the supported languages and ensure your document uses a supported language.
  1. Service Issues:
  • Temporary Outage: While rare, Google Cloud Vision API or Document AI could be experiencing temporary service issues. If the error is consistent across multiple documents and persists for an extended period, consider checking the Google Cloud Status Dashboard for any reported outages.
  • Quota Limits: If you're using the API extensively, you might be hitting your daily quota. Check your quota usage and consider adjusting your request frequency or increasing your quota if necessary.

In addition, according to Document AI release note dated February 16, 2024:

Enterprise Document OCR version 2.0, pretrained-ocr-v2.0-2023-06-02, is now Generally Available and ready for production workloads. Please migrate OCR workloads to this new processor version.

Ensure that you are working using the new version.

Furthermore, I recommend using Personalized Service Health as the first stop when facing a service disruption for specific products. Through Personalized Service Health you can view disruptions relevant to your projects. Read more about Personalized Service Health and how to integrate it into your incident management workflow.

Another option that I can suggest is filing an issue ticket or you may contact Google Cloud support for assistance. They can help diagnose the specific issue and provide more detailed guidance. 

Finally, you may keep an eye on the Document AI or Vision AI release notes for any latest updates or new features related to Enterprise Document OCR.

I hope the above information is helpful.