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

   ### Apache Airflow Provider(s)
   
   mongo
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Apache Airflow version
   
   2.10.2
   
   ### Operating System
   
   Redhat 9
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   _No response_
   
   ### What happened
   
   I create a new mongo connection on Airflow with the following input: 
   
![image](https://github.com/user-attachments/assets/8f6f8c6b-44a2-4837-bf11-4a2f5b7fe35c)
   
   When I try to call the connection on my task on Airflow:
   
   ```
   from airflow.providers.mongo.hooks.mongo import MongoHook
   @task
   def drop_table_from_mongo():
       mongo_conn = MongoHook(conn_id='QDATALAKE')
       #My code ...
       cnxn.close()
   ```
   
   I have this error:
   [2024-10-11, 08:44:07 UTC] {base.py:84} INFO - Retrieving connection 
'QDATALAKE'
   [2024-10-11, 08:44:07 UTC] {taskinstance.py:3310} ERROR - Task failed with 
exception
   Traceback (most recent call last):
     File 
"/opt/airflow/venv/lib/python3.9/site-packages/airflow/models/taskinstance.py", 
line 767, in _execute_task
       result = _execute_callable(context=context, **execute_callable_kwargs)
     File 
"/opt/airflow/venv/lib/python3.9/site-packages/airflow/models/taskinstance.py", 
line 733, in _execute_callable
       return ExecutionCallableRunner(
     File 
"/opt/airflow/venv/lib/python3.9/site-packages/airflow/utils/operator_helpers.py",
 line 252, in run
       return self.func(*args, **kwargs)
     File 
"/opt/airflow/venv/lib/python3.9/site-packages/airflow/models/baseoperator.py", 
line 406, in wrapper
       return func(self, *args, **kwargs)
     File 
"/opt/airflow/venv/lib/python3.9/site-packages/airflow/decorators/base.py", 
line 266, in execute
       return_value = super().execute(context)
     File 
"/opt/airflow/venv/lib/python3.9/site-packages/airflow/models/baseoperator.py", 
line 406, in wrapper
       return func(self, *args, **kwargs)
     File 
"/opt/airflow/venv/lib/python3.9/site-packages/airflow/operators/python.py", 
line 238, in execute
       return_value = self.execute_callable()
     File 
"/opt/airflow/venv/lib/python3.9/site-packages/airflow/operators/python.py", 
line 256, in execute_callable
       return runner.run(*self.op_args, **self.op_kwargs)
     File 
"/opt/airflow/venv/lib/python3.9/site-packages/airflow/utils/operator_helpers.py",
 line 252, in run
       return self.func(*args, **kwargs)
     File "/opt/airflow/dags/Erebia_Datalake_Source_Manuel.py", line 42, in 
drop_table_from_mongo
       mongo_conn = MongoHook(conn_id='QDATALAKE')
     File 
"/opt/airflow/venv/lib/python3.9/site-packages/airflow/providers/mongo/hooks/mongo.py",
 line 139, in __init__
       self.allow_insecure = self.extras.pop("allow_insecure", "false").lower() 
== "true"
   AttributeError: 'bool' object has no attribute 'lower'
   
   
   ### What you think should happen instead
   
   _No response_
   
   ### How to reproduce
   
   1. Create a new connection 
   2. Choose Mongo as type of connection
   3. Add Connection name, host, username, passeword and port
   4. Do not put anything in extra and do not check any option after extra
   5. Save the connection
   6. n a new Dag, import MongoHook 
   7. Create a @task and call the mongo connection (like in the example below)
   8. When the Dag is exacuted, the exception is raised as in the logs below. 
   
   ### 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