From c6f93a23a7d727b8280b2d2c49e9484481286903 Mon Sep 17 00:00:00 2001 From: bujjibabukatta Date: Tue, 4 Aug 2026 17:55:11 +0530 Subject: [PATCH 1/2] Stop dag processor from warning on every file path normalized for stats --- .../src/airflow/dag_processing/manager.py | 2 +- .../tests/unit/dag_processing/test_manager.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/airflow-core/src/airflow/dag_processing/manager.py b/airflow-core/src/airflow/dag_processing/manager.py index df0f8f8748135..fa13c3c39cc28 100644 --- a/airflow-core/src/airflow/dag_processing/manager.py +++ b/airflow-core/src/airflow/dag_processing/manager.py @@ -156,7 +156,7 @@ def presence_key(self) -> tuple[str, Path]: @property def normalized_file_path_for_stats(self) -> str: """Return the relative file path normalized for use in stats tags.""" - return normalize_name_for_stats(str(self.rel_path)) + return normalize_name_for_stats(str(self.rel_path), log_warning=False) def _config_int_factory(section: str, key: str): diff --git a/airflow-core/tests/unit/dag_processing/test_manager.py b/airflow-core/tests/unit/dag_processing/test_manager.py index f1fb4b66c81fd..9084edb293455 100644 --- a/airflow-core/tests/unit/dag_processing/test_manager.py +++ b/airflow-core/tests/unit/dag_processing/test_manager.py @@ -3620,3 +3620,20 @@ def test_get_team_names_batches_and_caches(self, mock_get_team_names): # Two bundles resolved in a single batched query; the repeat call is served from cache. mock_get_team_names.assert_called_once() assert manager._bundle_name_to_team_name == {"bundle_a": "team_alpha", "bundle_b": "team_alpha"} + + +def test_normalized_file_path_for_stats_does_not_warn(caplog): + """ + rel_path always contains "/" for any nested DAG file, so normalizing it for stats + always requires substitution -- this must not log a warning on every DAG file, every + processing cycle. + """ + dag_file_info = DagFileInfo( + bundle_name="testing", bundle_path=TEST_DAGS_FOLDER, rel_path=Path("dags/test/test_dag.py") + ) + + with caplog.at_level(logging.WARNING, logger="airflow._shared.observability.metrics.stats"): + result = dag_file_info.normalized_file_path_for_stats + + assert result == "dags_test_test_dag.py" + assert caplog.records == [] From af7ad06c54cd03b4f97e36168ababa09f62ee690 Mon Sep 17 00:00:00 2001 From: Ephraim Anierobi Date: Tue, 18 Aug 2026 10:36:26 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Ephraim Anierobi --- airflow-core/tests/unit/dag_processing/test_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow-core/tests/unit/dag_processing/test_manager.py b/airflow-core/tests/unit/dag_processing/test_manager.py index 9084edb293455..7bda30659a00e 100644 --- a/airflow-core/tests/unit/dag_processing/test_manager.py +++ b/airflow-core/tests/unit/dag_processing/test_manager.py @@ -3636,4 +3636,4 @@ def test_normalized_file_path_for_stats_does_not_warn(caplog): result = dag_file_info.normalized_file_path_for_stats assert result == "dags_test_test_dag.py" - assert caplog.records == [] + assert caplog.entries == []