You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "FarouziAbir (via GitHub)" <gi...@apache.org> on 2024/10/11 09:06:05 UTC
[I] [Mongodb Connection] AttributeError: 'bool' object has no attribute 'lower' [airflow]
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:

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: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Mongodb Connection] AttributeError: 'bool' object has no attribute 'lower' [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on issue #42930:
URL: https://github.com/apache/airflow/issues/42930#issuecomment-2406970590
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Mongodb Connection] AttributeError: 'bool' object has no attribute 'lower' [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #42930:
URL: https://github.com/apache/airflow/issues/42930#issuecomment-2409592514
Assigned!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Mongodb Connection] AttributeError: 'bool' object has no attribute 'lower' [airflow]
Posted by "romsharon98 (via GitHub)" <gi...@apache.org>.
romsharon98 closed issue #42930: [Mongodb Connection] AttributeError: 'bool' object has no attribute 'lower'
URL: https://github.com/apache/airflow/issues/42930
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Mongodb Connection] AttributeError: 'bool' object has no attribute 'lower' [airflow]
Posted by "AkhilVinayakp (via GitHub)" <gi...@apache.org>.
AkhilVinayakp commented on issue #42930:
URL: https://github.com/apache/airflow/issues/42930#issuecomment-2408456549
Try adding the connection via cli.
```
airflow connections add '<connection_id_name>' \
--conn-type 'mongo' \
--conn-host '<host-ip>' \
--conn-port '27017' \
--conn-login '<your-username>' \
--conn-password '<your-password>'
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Mongodb Connection] AttributeError: 'bool' object has no attribute 'lower' [airflow]
Posted by "build3r (via GitHub)" <gi...@apache.org>.
build3r commented on issue #42930:
URL: https://github.com/apache/airflow/issues/42930#issuecomment-2407335618
Looks like the issue is might because of the newly introduced check boxes fro mongo connection.
Minimal way to reproduce:
1. Setup mongo connection in Airflow UI
2. Open Python CLI on airflow server
3. Import mongo hook `from airflow.providers.mongo.hooks.mongo import MongoHook`
4. Try to connect `mongo_hook = MongoHook(mongo_conn_id='mongo_default')`
Connection fails with
`AttributeError: 'bool' object has no attribute 'lower'`
Removing the `.lower` from package works
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Mongodb Connection] AttributeError: 'bool' object has no attribute 'lower' [airflow]
Posted by "josix (via GitHub)" <gi...@apache.org>.
josix commented on issue #42930:
URL: https://github.com/apache/airflow/issues/42930#issuecomment-2409586771
It's probably caused from an inconsistent validation between [get_extra_dejson](https://github.com/apache/airflow/blob/20f82901f4437b8a6ce2831e4b0f9d245056ce7d/airflow/models/connection.py#L413) and MongoHook [initialization](https://github.com/apache/airflow/blob/20f82901f4437b8a6ce2831e4b0f9d245056ce7d/providers/src/airflow/providers/mongo/hooks/mongo.py#L141) when building the connection, I could help revamp the validation logics here, feel free to assign it to me, thanks.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org