Under which category would you file this issue?
Providers
Apache Airflow version
providers-google 21.1.0 (Airflow 3.2.1)
What happened and how to reproduce it?
GenAIGenerateContentOperator raises DefaultCredentialsError even when gcp_conn_id is set to a valid connection with a service account key.
The root cause is in GenAIGenerativeModelHook.get_genai_client():
providers/google/cloud/hooks/gen_ai.py
def get_genai_client(self, project_id: str, location: str):
return genai.Client(
vertexai=True,
project=project_id,
location=location,
)
The credentials parameter is not passed to genai.Client, so it falls back to Application Default Credentials. In environments where credentials are managed via Airflow
connections (e.g. Docker containers with service account keys), ADC doesn't exist and the call fails.
How to reproduce
- Configure a GCP connection in Airflow using a service account JSON key (not ADC)
- Use GenAIGenerateContentOperator with that gcp_conn_id
- Run in an environment without ADC configured (e.g. Docker)
What you think should happen instead?
The hook should pass the connection's credentials to the client, same as the old GenerativeModelHook did with vertexai.init(credentials=self.get_credentials()).
Operating System
Ubuntu 20.04.6 LTS
Deployment
Docker-Compose
Apache Airflow Provider(s)
google
Versions of Apache Airflow Providers
apache-airflow-providers-google==21.1.0
Official Helm Chart version
Not Applicable
Kubernetes Version
No response
Helm Chart configuration
No response
Docker Image customizations
No response
Anything else?
No response
Are you willing to submit PR?
Code of Conduct
Under which category would you file this issue?
Providers
Apache Airflow version
providers-google 21.1.0 (Airflow 3.2.1)
What happened and how to reproduce it?
GenAIGenerateContentOperator raises DefaultCredentialsError even when gcp_conn_id is set to a valid connection with a service account key.
The root cause is in GenAIGenerativeModelHook.get_genai_client():
providers/google/cloud/hooks/gen_ai.py
def get_genai_client(self, project_id: str, location: str):
return genai.Client(
vertexai=True,
project=project_id,
location=location,
)
The credentials parameter is not passed to genai.Client, so it falls back to Application Default Credentials. In environments where credentials are managed via Airflow
connections (e.g. Docker containers with service account keys), ADC doesn't exist and the call fails.
How to reproduce
What you think should happen instead?
The hook should pass the connection's credentials to the client, same as the old GenerativeModelHook did with vertexai.init(credentials=self.get_credentials()).
Operating System
Ubuntu 20.04.6 LTS
Deployment
Docker-Compose
Apache Airflow Provider(s)
google
Versions of Apache Airflow Providers
apache-airflow-providers-google==21.1.0
Official Helm Chart version
Not Applicable
Kubernetes Version
No response
Helm Chart configuration
No response
Docker Image customizations
No response
Anything else?
No response
Are you willing to submit PR?
Code of Conduct