Skip to content

Google Generative AI - Integration requesting reponse prior to file being analised. #140182

@judo16

Description

@judo16

The problem

When using Google Gnerative AI, it appears to be attempting to request an analysis before Google has finished processing the file. This results in the below error.

Error: Error generating content: 400 FAILED_PRECONDITION. {'error': {'code': 400, 'message': 'The File 5y6l7yja98jc is not in an ACTIVE state and usage is not allowed.', 'status': 'FAILED_PRECONDITION'}}

Their response is to wait a couple of seconds then try again. Is it possible to create a loop that checks every couple of seconds if the file is not yet processed?

What version of Home Assistant Core has the issue?

2025.3.1

What was the last working version of Home Assistant Core?

NA

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Google Generative AI

Link to integration documentation on our website

https://www.home-assistant.io/integrations/google_generative_ai_conversation

Diagnostics information

No response

Example YAML snippet

data:
  prompt: >-
    Wait until the file uploaded is "active" then describe what triggered the
    motion detection. If it looks like a false trigger, respond with dry humour.
  filenames:
    - "{{ video_filename }}"
response_variable: ai_description
action: google_generative_ai_conversation.generate_content

Anything in the logs that might be useful for us?

Error: Error generating content: 400 FAILED_PRECONDITION. {'error': {'code': 400, 'message': 'The File 5y6l7yja98jc is not in an ACTIVE state and usage is not allowed.', 'status': 'FAILED_PRECONDITION'}}

Additional information

Please note that error occurs with video files larger than 500kB. Pictures seem to work fine.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions