uranusjr commented on code in PR #41717:
URL: https://github.com/apache/airflow/pull/41717#discussion_r1755395336
##########
airflow/providers/mongo/hooks/mongo.py:
##########
@@ -118,6 +155,21 @@ def __init__(self, mongo_conn_id: str = default_conn_name,
*args, **kwargs) -> N
# Case: HTTP (ssl=False) with allow_insecure not specified
self.allow_insecure = False
+ @staticmethod
+ def _validate_connection(conn: Connection):
+ conn_type = conn.conn_type
+ if conn_type != "mongo":
+ if conn_type == "mongodb+srv":
+ raise AirflowConfigException(
+ "Mongo SRV connections should have the conn_type 'mongo'
and set 'use_srv=true' in extras"
+ )
+ raise AirflowConfigException(
+ f"conn_type '{conn_type}' not allowed for MongoHook; conn_type
must be 'mongo'"
+ )
+
+ if conn.port and "srv" in conn.extra_dejson and
conn.extra_dejson["srv"] is True:
Review Comment:
```suggestion
if conn.port and conn.extra_dejson.get("srv"):
```
--
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]