uplsh580 commented on code in PR #61036:
URL: https://github.com/apache/airflow/pull/61036#discussion_r2725430682
##########
airflow-core/src/airflow/utils/cli.py:
##########
@@ -436,6 +437,7 @@ def suppress_logs_and_warning(f: T) -> T:
@functools.wraps(f)
def _wrapper(*args, **kwargs):
_check_cli_args(args)
+ os.environ["_AIRFLOW_PROCESS_CONTEXT"] = "server"
Review Comment:
Query-type CLI commands (e.g., `dags list`) require the server context to
successfully initialize DAG bundles that depend on database-stored connections.
Providing the context here ensures consistent secret resolution via
MetastoreBackend across all read-only administrative tools. This centralization
also allows for the removal of redundant manual environment settings within
individual command functions like `connections_get`.
##########
airflow-core/src/airflow/utils/cli.py:
##########
@@ -107,6 +107,7 @@ def wrapper(*args, **kwargs):
from airflow.configuration import conf
from airflow.utils.db import check_and_run_migrations,
synchronize_log_template
+ os.environ["_AIRFLOW_PROCESS_CONTEXT"] = "server"
Review Comment:
Setting the server context here ensures that state-changing or heavy CLI
commands (like `dag-processor`, `db migrate`, or `tasks run`) have the
necessary privileges to access database-backed secrets. This is particularly
crucial for commands like `airflow dag-processor -B,` where DAG bundle
validation occurs during the command's initialization phase, before the actual
Job runner starts.
--
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]