amoghrajesh commented on code in PR #70681:
URL: https://github.com/apache/airflow/pull/70681#discussion_r4131477172


##########
airflow-core/src/airflow/configuration.py:
##########
@@ -760,17 +761,17 @@ def initialize_secrets_backends(
         from airflow.models import Connection
 
         custom_secret_backend._set_connection_class(Connection)
-        backend_list.append(custom_secret_backend)
+        backend_list.append((Backend.CUSTOM, custom_secret_backend))
 
     for class_name in default_backends:
         from airflow.models import Connection
 
         secrets_backend_cls = import_string(class_name)
         backend = secrets_backend_cls()
         backend._set_connection_class(Connection)
-        backend_list.append(backend)
+        backend_list.append((Backend.from_path(class_name), backend))
 
-    return backend_list
+    return sorted_backends(conf, backend_list, worker_mode)

Review Comment:
   This makes a bad `[secrets] backends_order` cause debugging airflow 
deployment to go into a deadlock.
   
   
   Look at this:
   ```shell
   [Breeze:3.11.16] root@23c5082cc375:/opt/airflow$ airflow config get-value 
secrets backends_order
   custom,environment_variable,metastore
   [Breeze:3.11.16] root@23c5082cc375:/opt/airflow$ airflow config get-value 
secrets backends_order
   ^C
   [Breeze:3.11.16] root@23c5082cc375:/opt/airflow$ export 
AIRFLOW__SECRETS__BACKENDS_ORDER=environment_variable,metastor
   airflow config get-value secrets backends_order
   Traceback (most recent call last):
     File "/usr/python/bin/airflow", line 4, in <module>
       from airflow.__main__ import main
     File "/opt/airflow/airflow-core/src/airflow/__init__.py", line 64, in 
<module>
       from airflow import configuration, settings
     File "/opt/airflow/airflow-core/src/airflow/configuration.py", line 821, 
in <module>
       secrets_backend_list = initialize_secrets_backends()
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/opt/airflow/airflow-core/src/airflow/configuration.py", line 774, 
in initialize_secrets_backends
       return sorted_backends(conf, backend_list, worker_mode)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/opt/airflow/airflow-core/src/airflow/_shared/configuration/secrets_backends.py",
 line 87, in sorted_backends
       backends_order = _get_secrets_backend_order(conf, [b[0] for b in 
backend_list], worker_mode)
                        
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/opt/airflow/airflow-core/src/airflow/_shared/configuration/secrets_backends.py",
 line 69, in _get_secrets_backend_order
       raise AirflowConfigException(
   airflow._shared.configuration.exceptions.AirflowConfigException: The 
configuration option [secrets]backends_order is misconfigured. The following 
backend types are unsupported: ['metastor']
   [Breeze:3.11.16] root@23c5082cc375:/opt/airflow$ airflow version
   Traceback (most recent call last):
     File "/usr/python/bin/airflow", line 4, in <module>
       from airflow.__main__ import main
     File "/opt/airflow/airflow-core/src/airflow/__init__.py", line 64, in 
<module>
       from airflow import configuration, settings
     File "/opt/airflow/airflow-core/src/airflow/configuration.py", line 821, 
in <module>
       secrets_backend_list = initialize_secrets_backends()
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/opt/airflow/airflow-core/src/airflow/configuration.py", line 774, 
in initialize_secrets_backends
       return sorted_backends(conf, backend_list, worker_mode)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/opt/airflow/airflow-core/src/airflow/_shared/configuration/secrets_backends.py",
 line 87, in sorted_backends
       backends_order = _get_secrets_backend_order(conf, [b[0] for b in 
backend_list], worker_mode)
                        
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/opt/airflow/airflow-core/src/airflow/_shared/configuration/secrets_backends.py",
 line 69, in _get_secrets_backend_order
       raise AirflowConfigException(
   airflow._shared.configuration.exceptions.AirflowConfigException: The 
configuration option [secrets]backends_order is misconfigured. The following 
backend types are unsupported: ['metastor']
   ```
   
   Rejecting a bad value is right behaviour but this bricks every entrypoint 
with a raw traceback, which isnt right at all.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to