From 1718d6caf25af1072c0f2005ba0b5c1207eab94d Mon Sep 17 00:00:00 2001 From: bramhanandlingala Date: Tue, 28 Jul 2026 12:11:59 +0530 Subject: [PATCH 1/2] Check GCSToAzureBlobStorageOperator match_glob support after template rendering --- .../microsoft/azure/transfers/gcs_to_wasb.py | 4 ++-- .../azure/transfers/test_gcs_to_wasb.py | 17 ++++++++++------- .../prek/validate_operators_init_exemptions.txt | 1 - 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/gcs_to_wasb.py b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/gcs_to_wasb.py index acdc0fa65ea5e..c4e5d74783d8e 100644 --- a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/gcs_to_wasb.py +++ b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/gcs_to_wasb.py @@ -131,8 +131,6 @@ def __init__( self._is_match_glob_supported = False except ImportError: self._is_match_glob_supported = False - if not self._is_match_glob_supported and match_glob: - raise ValueError("The 'match_glob' parameter requires 'apache-airflow-providers-google>=10.3.0'.") self.match_glob = match_glob def _transform_file_path(self, file_path: str) -> str: @@ -179,6 +177,8 @@ def execute(self, context: Context) -> list[str]: } if self._is_match_glob_supported: list_kwargs["match_glob"] = self.match_glob + elif self.match_glob: + raise ValueError("The 'match_glob' parameter requires 'apache-airflow-providers-google>=10.3.0'.") gcs_files = gcs_hook.list(**list_kwargs) # type: ignore[call-arg] diff --git a/providers/microsoft/azure/tests/unit/microsoft/azure/transfers/test_gcs_to_wasb.py b/providers/microsoft/azure/tests/unit/microsoft/azure/transfers/test_gcs_to_wasb.py index 27d61b0c2ae45..f03d966db8d78 100644 --- a/providers/microsoft/azure/tests/unit/microsoft/azure/transfers/test_gcs_to_wasb.py +++ b/providers/microsoft/azure/tests/unit/microsoft/azure/transfers/test_gcs_to_wasb.py @@ -49,14 +49,17 @@ def test_init_defaults(self): assert op.create_container is False @mock.patch("airflow.providers.google.__version__", "10.2.0") - def test_match_glob_requires_recent_google_provider(self): + @mock.patch("airflow.providers.microsoft.azure.transfers.gcs_to_wasb.WasbHook") + @mock.patch("airflow.providers.microsoft.azure.transfers.gcs_to_wasb.GCSHook") + def test_match_glob_requires_recent_google_provider(self, mock_gcs_hook, mock_wasb_hook): + op = GCSToAzureBlobStorageOperator( + task_id=TASK_ID, + gcs_bucket=GCS_BUCKET, + container_name=CONTAINER, + match_glob="**/*.csv", + ) with pytest.raises(ValueError, match="match_glob"): - GCSToAzureBlobStorageOperator( - task_id=TASK_ID, - gcs_bucket=GCS_BUCKET, - container_name=CONTAINER, - match_glob="**/*.csv", - ) + op.execute(context=None) @mock.patch("airflow.providers.microsoft.azure.transfers.gcs_to_wasb.WasbHook") @mock.patch("airflow.providers.microsoft.azure.transfers.gcs_to_wasb.GCSHook") diff --git a/scripts/ci/prek/validate_operators_init_exemptions.txt b/scripts/ci/prek/validate_operators_init_exemptions.txt index 76ba180595a56..d22dc801bef73 100644 --- a/scripts/ci/prek/validate_operators_init_exemptions.txt +++ b/scripts/ci/prek/validate_operators_init_exemptions.txt @@ -28,6 +28,5 @@ providers/google/src/airflow/providers/google/cloud/transfers/bigquery_to_mssql. providers/google/src/airflow/providers/google/cloud/transfers/gcs_to_bigquery.py::GCSToBigQueryOperator providers/google/src/airflow/providers/google/cloud/transfers/gcs_to_gcs.py::GCSToGCSOperator providers/google/src/airflow/providers/google/marketing_platform/operators/campaign_manager.py::GoogleCampaignManagerDeleteReportOperator -providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/gcs_to_wasb.py::GCSToAzureBlobStorageOperator providers/microsoft/psrp/src/airflow/providers/microsoft/psrp/operators/psrp.py::PsrpOperator providers/standard/src/airflow/providers/standard/operators/bash.py::BashOperator From 1247839407a1603335e4887fc8993a4ddd85246e Mon Sep 17 00:00:00 2001 From: bramhanandlingala Date: Thu, 30 Jul 2026 16:57:22 +0530 Subject: [PATCH 2/2] Restore match_glob provision check in __init__ per #70296 rules --- .../microsoft/azure/transfers/gcs_to_wasb.py | 4 ++-- .../microsoft/azure/transfers/test_gcs_to_wasb.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/gcs_to_wasb.py b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/gcs_to_wasb.py index c4e5d74783d8e..af10c59cafcce 100644 --- a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/gcs_to_wasb.py +++ b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/gcs_to_wasb.py @@ -132,6 +132,8 @@ def __init__( except ImportError: self._is_match_glob_supported = False self.match_glob = match_glob + if not self._is_match_glob_supported and match_glob is not None: + raise ValueError("The 'match_glob' parameter requires 'apache-airflow-providers-google>=10.3.0'.") def _transform_file_path(self, file_path: str) -> str: """ @@ -177,8 +179,6 @@ def execute(self, context: Context) -> list[str]: } if self._is_match_glob_supported: list_kwargs["match_glob"] = self.match_glob - elif self.match_glob: - raise ValueError("The 'match_glob' parameter requires 'apache-airflow-providers-google>=10.3.0'.") gcs_files = gcs_hook.list(**list_kwargs) # type: ignore[call-arg] diff --git a/providers/microsoft/azure/tests/unit/microsoft/azure/transfers/test_gcs_to_wasb.py b/providers/microsoft/azure/tests/unit/microsoft/azure/transfers/test_gcs_to_wasb.py index f03d966db8d78..3ec866a73a637 100644 --- a/providers/microsoft/azure/tests/unit/microsoft/azure/transfers/test_gcs_to_wasb.py +++ b/providers/microsoft/azure/tests/unit/microsoft/azure/transfers/test_gcs_to_wasb.py @@ -52,14 +52,14 @@ def test_init_defaults(self): @mock.patch("airflow.providers.microsoft.azure.transfers.gcs_to_wasb.WasbHook") @mock.patch("airflow.providers.microsoft.azure.transfers.gcs_to_wasb.GCSHook") def test_match_glob_requires_recent_google_provider(self, mock_gcs_hook, mock_wasb_hook): - op = GCSToAzureBlobStorageOperator( - task_id=TASK_ID, - gcs_bucket=GCS_BUCKET, - container_name=CONTAINER, - match_glob="**/*.csv", - ) with pytest.raises(ValueError, match="match_glob"): - op.execute(context=None) + GCSToAzureBlobStorageOperator( + task_id=TASK_ID, + gcs_bucket=GCS_BUCKET, + container_name=CONTAINER, + match_glob="**/*.csv", + ) + mock_gcs_hook.return_value.list.assert_not_called() @mock.patch("airflow.providers.microsoft.azure.transfers.gcs_to_wasb.WasbHook") @mock.patch("airflow.providers.microsoft.azure.transfers.gcs_to_wasb.GCSHook")