Document AI – “Invalid location: 'eu' must match 'us'” & “Processor Not Found” error despite correct config

Hi community,

I’m working on a Google Cloud Function that processes invoices using Document AI. The function is triggered by a file upload to a Cloud Storage bucket. However, when testing locally and deploying, I run into this error:

AttributeError: 'NoneType' object has no attribute 'X'

Here’s what I’ve confirmed so far:

  • The Cloud Function is correctly triggered on file upload.
  • Document AI processor ID, project ID, and location are defined using environment variables.
  • I’m using documentai.DocumentProcessorServiceClient().process_document(...) as per the official Python SDK.

The processor exists in the EU region, and I’ve double-checked the processor_path() and request structure. Despite this, it seems that the result.document is coming back as None, or possibly result itself is None.

Has anyone encountered this before when integrating Document AI with Cloud Functions? What are common causes for NoneType responses here?

Any help or direction is greatly appreciated :folded_hands:

Hi @Melon_Accountants,

Here are some reasons why Document AI might be giving you NoneType responses:

  • Regional Endpoint Mismatch: By default, the API client uses the US endpoint. As discussed in a related discussion, you need to configure the client to use the correct regional endpoint to avoid issues.
  • Incorrect Project/Process ID/Process Path: Double-check for any typos or misconfigurations in these values.
  • Permissions: Ensure that the service account you are using has the necessary permission to access Document API.
  • Invalid Document Type: The file you’re sending may be corrupted or empty or you might be specifying the wrong mime_type. Verify the file content and refer to this related discussion for more details.

For additional help, this documentation may be useful for resolving some Document AI errors.