natanweinberger commented on a change in pull request #15425:
URL: https://github.com/apache/airflow/pull/15425#discussion_r628453598



##########
File path: airflow/secrets/local_filesystem.py
##########
@@ -263,19 +71,32 @@ def load_connections_dict(file_path: str) -> Dict[str, 
Any]:
     :return: A dictionary where the key contains a connection ID and the value 
contains the connection.
     :rtype: Dict[str, airflow.models.connection.Connection]
     """
+    from airflow.models.connection import Connection
+
     log.debug("Loading connection")
 
-    secrets: Dict[str, Any] = _parse_secret_file(file_path)
+    secrets: Dict[str, Any] = _parse_file(file_path)
     connection_by_conn_id = {}
     for key, secret_values in list(secrets.items()):
         if isinstance(secret_values, list):
-            if len(secret_values) > 1:
+            # secret_values is either length 0, 1 or 2+ -- only length 1 is 
valid
+            if not secret_values:
+                log.debug("No secret values for %s", key)
+                continue
+
+            if len(secret_values) >= 2:
                 raise ConnectionNotUnique(f"Found multiple values for {key} in 
{file_path}.")
 
-            for secret_value in secret_values:
-                connection_by_conn_id[key] = _create_connection(key, 
secret_value)
+            # secret_values must be of length one, so unpack it
+            elif secret_values:
+                secret_values = secret_values[0]
+
+        if isinstance(secret_values, dict):
+            connection_by_conn_id[key] = Connection.from_dict(key, 
secret_values)

Review comment:
       Creating a method `Connection.from_dict` was a suggestion from @mik-laj: 
https://github.com/apache/airflow/pull/15425#discussion_r615929569




-- 
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.

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


Reply via email to