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 d25d5410791 fix: Check dynamic transport env vars in is_disabled() 
(#53370)
d25d5410791 is described below

commit d25d541079188ddcd98180071bed4277150ac08e
Author: Kacper Muda <[email protected]>
AuthorDate: Tue Jul 15 23:05:55 2025 +0200

    fix: Check dynamic transport env vars in is_disabled() (#53370)
---
 .../src/airflow/providers/openlineage/conf.py      | 14 +++++++--
 .../tests/unit/openlineage/test_conf.py            | 33 ++++++++++++++++++++++
 2 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/providers/openlineage/src/airflow/providers/openlineage/conf.py 
b/providers/openlineage/src/airflow/providers/openlineage/conf.py
index c7300d298e2..21e905bf88b 100644
--- a/providers/openlineage/src/airflow/providers/openlineage/conf.py
+++ b/providers/openlineage/src/airflow/providers/openlineage/conf.py
@@ -136,9 +136,17 @@ def is_disabled() -> bool:
     if _is_true(os.getenv("OPENLINEAGE_DISABLED", "")):  # Check legacy 
variable
         return True
 
-    # Check if both 'transport' and 'config_path' are not present and also
-    # if legacy 'OPENLINEAGE_URL' environment variables is not set
-    return transport() == {} and config_path(True) == "" and 
os.getenv("OPENLINEAGE_URL", "") == ""
+    if transport():  # Check if transport is present
+        return False
+    if config_path(True):  # Check if config file is present
+        return False
+    if os.getenv("OPENLINEAGE_URL"):  # Check if url simple env var is present
+        return False
+    # Check if any transport configuration env var is present
+    if any(k.startswith("OPENLINEAGE__TRANSPORT") and v for k, v in 
os.environ.items()):
+        return False
+
+    return True  # No transport configuration is present, we can disable 
OpenLineage
 
 
 @cache
diff --git a/providers/openlineage/tests/unit/openlineage/test_conf.py 
b/providers/openlineage/tests/unit/openlineage/test_conf.py
index cdfb27d406b..c8b5441fd4d 100644
--- a/providers/openlineage/tests/unit/openlineage/test_conf.py
+++ b/providers/openlineage/tests/unit/openlineage/test_conf.py
@@ -476,6 +476,39 @@ def test_is_disabled_empty_conf_option():
     assert is_disabled() is True
 
 
[email protected](os.environ, {_VAR_URL: "", "OPENLINEAGE__TRANSPORT": 
'{"type": "console"}'}, clear=True)
+@conf_vars(
+    {
+        (_CONFIG_SECTION, _CONFIG_OPTION_CONFIG_PATH): "",
+        (_CONFIG_SECTION, _CONFIG_OPTION_TRANSPORT): "",
+    }
+)
+def test_is_disabled_env_variables_present():
+    assert is_disabled() is False
+
+
[email protected](os.environ, {_VAR_URL: "", "OPENLINEAGE__TRANSPORT": ""}, 
clear=True)
+@conf_vars(
+    {
+        (_CONFIG_SECTION, _CONFIG_OPTION_CONFIG_PATH): "",
+        (_CONFIG_SECTION, _CONFIG_OPTION_TRANSPORT): "",
+    }
+)
+def test_is_disabled_env_variables_not_present():
+    assert is_disabled() is True
+
+
[email protected](os.environ, {_VAR_URL: "", "OPENLINEAGE__TRANSPOR": '{"type": 
"console"}'}, clear=True)
+@conf_vars(
+    {
+        (_CONFIG_SECTION, _CONFIG_OPTION_CONFIG_PATH): "",
+        (_CONFIG_SECTION, _CONFIG_OPTION_TRANSPORT): "",
+    }
+)
+def test_is_disabled_env_variables_not_present_typo():
+    assert is_disabled() is True
+
+
 @mock.patch.dict(os.environ, {_VAR_URL: ""}, clear=True)
 @conf_vars(
     {

Reply via email to