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 d5a161024b5 Declare allow_driver_in_extra in the ODBC provider 
configuration metadata (#72547)
d5a161024b5 is described below

commit d5a161024b5ce68196d13612060320929e132b0f
Author: PoAn Yang <[email protected]>
AuthorDate: Wed Sep 9 09:52:45 2026 +0900

    Declare allow_driver_in_extra in the ODBC provider configuration metadata 
(#72547)
    
    Signed-off-by: PoAn Yang <[email protected]>
---
 providers/odbc/docs/configurations-ref.rst            | 19 +++++++++++++++++++
 providers/odbc/docs/connections/odbc.rst              |  2 +-
 providers/odbc/docs/index.rst                         |  1 +
 providers/odbc/provider.yaml                          | 14 ++++++++++++++
 .../src/airflow/providers/odbc/get_provider_info.py   | 14 ++++++++++++++
 providers/odbc/tests/unit/odbc/hooks/test_odbc.py     | 16 ++++++++++++++++
 6 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/providers/odbc/docs/configurations-ref.rst 
b/providers/odbc/docs/configurations-ref.rst
new file mode 100644
index 00000000000..a52b21b2e56
--- /dev/null
+++ b/providers/odbc/docs/configurations-ref.rst
@@ -0,0 +1,19 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+ ..   http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+.. include:: 
/../../../devel-common/src/sphinx_exts/includes/providers-configurations-ref.rst
+.. include:: 
/../../../devel-common/src/sphinx_exts/includes/sections-and-options.rst
diff --git a/providers/odbc/docs/connections/odbc.rst 
b/providers/odbc/docs/connections/odbc.rst
index d156f553b1d..6f3544fcd5f 100644
--- a/providers/odbc/docs/connections/odbc.rst
+++ b/providers/odbc/docs/connections/odbc.rst
@@ -73,7 +73,7 @@ Extra (optional)
           this config from env vars, use 
``AIRFLOW__PROVIDERS_ODBC__ALLOW_DRIVER_IN_EXTRA=true``.
 
     .. note::
-        If setting ``allow_driver_extra`` to True, this allows users to set 
the driver via the Airflow Connection's
+        If setting ``allow_driver_in_extra`` to True, this allows users to set 
the driver via the Airflow Connection's
         ``extra`` field.  By default this is not allowed.  If enabling this 
functionality, you should make sure
         that you trust the users who can edit connections in the UI to not use 
it maliciously.
 
diff --git a/providers/odbc/docs/index.rst b/providers/odbc/docs/index.rst
index 149d2774eba..3f3e82afd1c 100644
--- a/providers/odbc/docs/index.rst
+++ b/providers/odbc/docs/index.rst
@@ -34,6 +34,7 @@
     :maxdepth: 1
     :caption: Guides
 
+    Configuration <configurations-ref>
     Connection types <connections/odbc>
     Operators <operators>
 
diff --git a/providers/odbc/provider.yaml b/providers/odbc/provider.yaml
index a52b8c4df72..ebd6ac83917 100644
--- a/providers/odbc/provider.yaml
+++ b/providers/odbc/provider.yaml
@@ -90,3 +90,17 @@ connection-types:
   - hook-class-name: airflow.providers.odbc.hooks.odbc.OdbcHook
     hook-name: "ODBC"
     connection-type: odbc
+
+config:
+  providers.odbc:
+    description: This section applies for the ODBC provider and connection 
type.
+    options:
+      allow_driver_in_extra:
+        description: |
+          Whether to allow using ``driver`` set in the connection's ``extra`` 
field. If set to False,
+          ``driver`` will be ignored. If enabling this functionality, you 
should make sure that you
+          trust the users who can edit connections to not use it maliciously.
+        version_added: "4.0.0"
+        type: boolean
+        example: ~
+        default: "False"
diff --git a/providers/odbc/src/airflow/providers/odbc/get_provider_info.py 
b/providers/odbc/src/airflow/providers/odbc/get_provider_info.py
index 31f6fb9451b..f98bfaa806c 100644
--- a/providers/odbc/src/airflow/providers/odbc/get_provider_info.py
+++ b/providers/odbc/src/airflow/providers/odbc/get_provider_info.py
@@ -43,4 +43,18 @@ def get_provider_info():
                 "connection-type": "odbc",
             }
         ],
+        "config": {
+            "providers.odbc": {
+                "description": "This section applies for the ODBC provider and 
connection type.",
+                "options": {
+                    "allow_driver_in_extra": {
+                        "description": "Whether to allow using ``driver`` set 
in the connection's ``extra`` field. If set to False,\n``driver`` will be 
ignored. If enabling this functionality, you should make sure that you\ntrust 
the users who can edit connections to not use it maliciously.\n",
+                        "version_added": "4.0.0",
+                        "type": "boolean",
+                        "example": None,
+                        "default": "False",
+                    }
+                },
+            }
+        },
     }
diff --git a/providers/odbc/tests/unit/odbc/hooks/test_odbc.py 
b/providers/odbc/tests/unit/odbc/hooks/test_odbc.py
index ed55eaf8e94..5599c7212dc 100644
--- a/providers/odbc/tests/unit/odbc/hooks/test_odbc.py
+++ b/providers/odbc/tests/unit/odbc/hooks/test_odbc.py
@@ -236,6 +236,22 @@ class TestOdbcHook:
         )
         assert hook.driver == "Blah driver"
 
+    def test_allow_driver_in_extra_is_declared_in_provider_config(self):
+        """
+        The hook reads ``[providers.odbc] allow_driver_in_extra``. The option 
has to be declared in
+        ``provider.yaml`` so that ``airflow config list`` and the 
configuration reference know about it.
+        """
+        from airflow.providers.odbc.get_provider_info import get_provider_info
+
+        option = 
get_provider_info()["config"]["providers.odbc"]["options"]["allow_driver_in_extra"]
+        assert option["type"] == "boolean"
+        assert option["default"] == "False"
+
+    def test_allow_driver_in_extra_default_is_resolved_without_fallback(self):
+        from airflow.providers.common.compat.sdk import conf
+
+        assert conf.getboolean("providers.odbc", "allow_driver_in_extra") is 
False
+
     def test_default_driver_set(self):
         with patch.object(OdbcHook, "default_driver", "Blah driver"):
             hook = mock_db_hook(OdbcHook)

Reply via email to