You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2026/03/12 22:31:04 UTC

Re: [PR] Fix connection resolution in CLI by setting server process context in decorators [airflow]

potiuk commented on code in PR #61036:
URL: https://github.com/apache/airflow/pull/61036#discussion_r2927763013


##########
airflow-core/src/airflow/utils/cli.py:
##########
@@ -101,7 +101,12 @@ def wrapper(*args, **kwargs):
                 root_logger.setLevel(logging.DEBUG)
                 for handler in root_logger.handlers:
                     handler.setLevel(logging.DEBUG)
+            # Save original value and restore after context ends
+            original_value = os.environ.get("_AIRFLOW_PROCESS_CONTEXT")
             try:
+                # Set process context to "server" for the entire function execution
+                # This ensures connection resolution works correctly throughout the CLI command

Review Comment:
   **Bug / Design issue**: The process context is set unconditionally, but the PR description says it should only be set "when `check_db` is True". More importantly, setting `server` context for **every** `action_cli`-decorated command is overly broad — it grants MetastoreBackend access to commands that don't need it (e.g., `airflow info`, `airflow cheat-sheet`).
   
   The original bug is specifically about `dag-processor -B` needing server context for `validate_dag_bundle_arg()`. A more targeted fix would be to set server context only where it's actually needed.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org