From dce7b82475fbb58ba1d632ce10335aef9aa2f6a0 Mon Sep 17 00:00:00 2001 From: mohasoori <159259906+mohasoori@users.noreply.github.com> Date: Thu, 13 Feb 2025 15:00:18 +0100 Subject: [PATCH 1/2] Fix: Strip newline characters from dag_integrity_exceptions.txt entries The readlines module does not strip newline characters (\n) from the output, causing entries in dag_integrity_exceptions.txt to include them. This leads to incorrect comparisons and breaks the logic. By stripping the output, we ensure that DAG names are correctly matched as defined in dag_integrity_exceptions.txt. Example output before fix: Exceptions: ['# Add dag files to exempt from parse test below. ex: dags/\n', 'dags/dag_example1\n', 'dags/dag_example2.py'] --- airflow/include/dagintegritytestdefault.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/include/dagintegritytestdefault.py b/airflow/include/dagintegritytestdefault.py index e433703be..b1b91fceb 100644 --- a/airflow/include/dagintegritytestdefault.py +++ b/airflow/include/dagintegritytestdefault.py @@ -131,7 +131,7 @@ def test_file_imports(rel_path, rv): """Test for import errors on a file""" if os.path.exists(".astro/dag_integrity_exceptions.txt"): with open(".astro/dag_integrity_exceptions.txt", "r") as f: - exceptions = f.readlines() + exceptions = [line.rstrip() for line in f] print(f"Exceptions: {exceptions}") if (rv != "No import errors") and rel_path not in exceptions: # If rv is not "No import errors," consider it a failed test From 98670027603ce21a281b395977e51c385787c539 Mon Sep 17 00:00:00 2001 From: mohasoori <159259906+mohasoori@users.noreply.github.com> Date: Thu, 13 Feb 2025 15:19:21 +0100 Subject: [PATCH 2/2] Update dagintegritytestdefault.py Used strip() to remove leading and trailing whitespace --- airflow/include/dagintegritytestdefault.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/include/dagintegritytestdefault.py b/airflow/include/dagintegritytestdefault.py index b1b91fceb..ce5412d5e 100644 --- a/airflow/include/dagintegritytestdefault.py +++ b/airflow/include/dagintegritytestdefault.py @@ -131,7 +131,7 @@ def test_file_imports(rel_path, rv): """Test for import errors on a file""" if os.path.exists(".astro/dag_integrity_exceptions.txt"): with open(".astro/dag_integrity_exceptions.txt", "r") as f: - exceptions = [line.rstrip() for line in f] + exceptions = [line.strip() for line in f] print(f"Exceptions: {exceptions}") if (rv != "No import errors") and rel_path not in exceptions: # If rv is not "No import errors," consider it a failed test