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

vatsrahul1001 pushed a commit to branch v3-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-3-test by this push:
     new d8cf70ad04f [v3-3-test] Flag missing conn-fields when hook-only files 
change in static checks (#70007) (#70214)
d8cf70ad04f is described below

commit d8cf70ad04fe418d2746d11d4636879c8d42b330
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Jul 31 10:25:06 2026 +0530

    [v3-3-test] Flag missing conn-fields when hook-only files change in static 
checks (#70007) (#70214)
    
     Flag missing conn-fields when hook-only files change in static checks 
(#70007)
---
 providers/.pre-commit-config.yaml                            |  5 ++++-
 scripts/ci/prek/check_provider_conn_fields.py                | 12 +++++++-----
 .../ci/prek/test_check_conn_fields_match_form_widgets.py     |  8 ++++++--
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/providers/.pre-commit-config.yaml 
b/providers/.pre-commit-config.yaml
index ea38696d7c1..ab6fef5a7f0 100644
--- a/providers/.pre-commit-config.yaml
+++ b/providers/.pre-commit-config.yaml
@@ -240,7 +240,10 @@ repos:
         name: Validate provider.yaml files
         entry: ../scripts/ci/prek/check_provider_yaml_files.py
         language: python
-        files: ^.*/provider\.yaml$
+        files: >
+          (?x)
+          ^.*/provider\.yaml$|
+          ^.*/src/airflow/providers/.*/hooks/[^/]+\.py$
         exclude: ^.*/.venv/.*$
         require_serial: true
       - id: check-cli-definition-imports
diff --git a/scripts/ci/prek/check_provider_conn_fields.py 
b/scripts/ci/prek/check_provider_conn_fields.py
index 8d50c16335b..9980095b83c 100644
--- a/scripts/ci/prek/check_provider_conn_fields.py
+++ b/scripts/ci/prek/check_provider_conn_fields.py
@@ -46,6 +46,11 @@ def check_conn_fields_for_entry(
       at all — the entry is then skipped entirely (no ``conn-fields`` check), 
or
     - raises any other ``Exception`` to signal an unexpected failure (converted
       here into an error string so callers never need to catch it).
+
+    When the hook returns widgets, the ``conn-fields`` section in the provider 
YAML
+    must exactly match.  If ``conn-fields`` is absent, every widget key is 
treated
+    as missing from YAML (because any custom field missing from 
``conn-fields`` will
+    be invisible in the new React connection UI).
     """
     hook_class_name: str = conn_type_entry["hook-class-name"]
     connection_type: str = conn_type_entry.get("connection-type", "?")
@@ -61,11 +66,8 @@ def check_conn_fields_for_entry(
     if widget_keys is None:
         return []
 
-    conn_fields = conn_type_entry.get("conn-fields")
-    if conn_fields is None:
-        # No conn-fields declared: the new UI simply exposes no custom fields 
for this
-        # connection type, which is intentional.  Nothing to validate.
-        return []
+    # Treat absent conn-fields as an empty dict so any hook widget is flagged 
as missing.
+    conn_fields: dict = conn_type_entry.get("conn-fields") or {}
 
     error = build_mismatch_error(
         set(conn_fields.keys()), widget_keys, connection_type, yaml_file_path, 
hook_class_name
diff --git a/scripts/tests/ci/prek/test_check_conn_fields_match_form_widgets.py 
b/scripts/tests/ci/prek/test_check_conn_fields_match_form_widgets.py
index db63f6783aa..271bd9a88c6 100644
--- a/scripts/tests/ci/prek/test_check_conn_fields_match_form_widgets.py
+++ b/scripts/tests/ci/prek/test_check_conn_fields_match_form_widgets.py
@@ -107,8 +107,8 @@ class TestCheckConnFieldsForEntry:
             pytest.param([], _get_keys(), id="empty-on-both-sides"),
             pytest.param(["a"], _skip, 
id="skip-hook-without-get-connection-form-widgets"),
             pytest.param(None, _skip, 
id="skip-missing-conn-fields-when-hook-has-no-widgets"),
-            # Hook with widgets but no conn-fields is allowed: new UI 
intentionally omits custom fields.
-            pytest.param(None, _get_keys("field_a"), 
id="no-conn-fields-with-hook-widgets-is-ok"),
+            # When hook has no custom widgets, absent conn-fields is fine.
+            pytest.param(None, lambda _: set(), 
id="no-conn-fields-no-hook-widgets-is-ok"),
         ],
     )
     def test_no_errors(self, conn_fields, get_keys):
@@ -123,6 +123,10 @@ class TestCheckConnFieldsForEntry:
             ),
             pytest.param(["a"], _raise, "boom", 
id="unexpected-exception-message"),
             pytest.param(["a"], _raise, HOOK_CLASS, 
id="unexpected-exception-mentions-hook-class"),
+            # absent conn-fields with hook widgets must be flagged (every 
widget key is "missing")
+            pytest.param(
+                None, _get_keys("auth_protocol"), "auth_protocol", 
id="absent-conn-fields-with-hook-widgets"
+            ),
         ],
     )
     def test_one_error_containing(self, conn_fields, get_keys, 
expected_in_error):

Reply via email to