This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 39a4dfc6666 fix: fixing unable to import list value for variable 
(#61508)
39a4dfc6666 is described below

commit 39a4dfc6666f58fde1f2d676c93da35a9c614aaa
Author: Itay Adler <[email protected]>
AuthorDate: Sun Feb 15 23:36:41 2026 +0200

    fix: fixing unable to import list value for variable (#61508)
    
    * fix: fixing unable to import list value for variable
    
    * adding another pytest test case to test the bug fix
---
 airflow-core/src/airflow/secrets/local_filesystem.py | 20 +++++++++++++++-----
 .../unit/always/test_secrets_local_filesystem.py     |  1 +
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/airflow-core/src/airflow/secrets/local_filesystem.py 
b/airflow-core/src/airflow/secrets/local_filesystem.py
index b590375ffe8..dc247d969be 100644
--- a/airflow-core/src/airflow/secrets/local_filesystem.py
+++ b/airflow-core/src/airflow/secrets/local_filesystem.py
@@ -231,7 +231,7 @@ def _create_connection(conn_id: str, value: Any):
     )
 
 
-def load_variables(file_path: str) -> dict[str, str]:
+def load_variables(file_path: str) -> dict[str, Any]:
     """
     Load variables from a text file.
 
@@ -241,11 +241,21 @@ def load_variables(file_path: str) -> dict[str, str]:
     """
     log.debug("Loading variables from a text file")
 
+    ext = Path(file_path).suffix.lstrip(".").lower()
     secrets = _parse_secret_file(file_path)
-    invalid_keys = [key for key, values in secrets.items() if 
isinstance(values, list) and len(values) != 1]
-    if invalid_keys:
-        raise VariableNotUnique(f'The "{file_path}" file contains multiple 
values for keys: {invalid_keys}')
-    variables = {key: values[0] if isinstance(values, list) else values for 
key, values in secrets.items()}
+
+    if ext == "env":
+        invalid_keys = [
+            key for key, values in secrets.items() if isinstance(values, list) 
and len(values) != 1
+        ]
+        if invalid_keys:
+            raise VariableNotUnique(
+                f'The "{file_path}" file contains multiple values for keys: 
{invalid_keys}'
+            )
+        variables = {key: values[0] for key, values in secrets.items()}
+    else:
+        variables = dict(secrets)
+
     log.debug("Loaded %d variables: ", len(variables))
     return variables
 
diff --git a/airflow-core/tests/unit/always/test_secrets_local_filesystem.py 
b/airflow-core/tests/unit/always/test_secrets_local_filesystem.py
index fddcbf99838..833b7ae36fa 100644
--- a/airflow-core/tests/unit/always/test_secrets_local_filesystem.py
+++ b/airflow-core/tests/unit/always/test_secrets_local_filesystem.py
@@ -121,6 +121,7 @@ class TestLoadVariables:
             ({}, {}),
             ({"KEY": "AAA"}, {"KEY": "AAA"}),
             ({"KEY_A": "AAA", "KEY_B": "BBB"}, {"KEY_A": "AAA", "KEY_B": 
"BBB"}),
+            ({"KEY": [{"AAA": "BBB"}, {"CCC": "DDD"}]}, {"KEY": [{"AAA": 
"BBB"}, {"CCC": "DDD"}]}),
         ],
     )
     def test_json_file_should_load_variables(self, file_content, 
expected_variables):

Reply via email to