yershovkiril opened a new issue, #65709:
URL: https://github.com/apache/airflow/issues/65709

   ### 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                                                        
                                                                                
                         
                                                                                
                                                                                
                    
     1. Configure a GCP connection in Airflow using a service account JSON key 
(not ADC)
     2. Use GenAIGenerateContentOperator with that gcp_conn_id
     3. 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?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to