Skip to content

Guard _load_logging_config when remote log handler discovery fails#67504

Open
potiuk wants to merge 1 commit into
apache:mainfrom
potiuk:guard-load-logging-config-discovery
Open

Guard _load_logging_config when remote log handler discovery fails#67504
potiuk wants to merge 1 commit into
apache:mainfrom
potiuk:guard-load-logging-config-discovery

Conversation

@potiuk
Copy link
Copy Markdown
Member

@potiuk potiuk commented May 25, 2026

_load_logging_config called discover_remote_log_handler without exception protection. A raise there propagated through load_remote_log_handler (which is called transitively from any logger acquisition path) into the task lifecycle handler, crashing the task with a non-obvious error.

The earlier PR #66571 fixed the "no handler available" signal; the gap was that the discovery call itself wasn't guarded.

Reported as F-005 in the apache/tooling-agents L3 task-sdk sweep 0920c77.

Change

Wrap discover_remote_log_handler in try/except. On failure, emit a warning to the dedicated airflow.logging.remote structlog logger (same logger PR #66571 uses for remote_log_handler_unavailable / remote_log_upload_failed) and fall back to "no remote handler" so the rest of the logging system initialises and the task can run with local logs only.

Test plan

  • test_discovery_failure_warns_and_falls_back — patches discover_remote_log_handler to raise ImportError; asserts the warning lands with exc_info, _ActiveLoggingConfig.remote_task_log is None, and logging_config_loaded is True (so we don't loop trying to re-discover).
  • test_discovery_success_no_warning — success path emits no warning and the returned handler is cached.
  • prek run ruff clean.
  • prek run mypy-task-sdk clean.
  • Full test_log.py suite passes.

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.7)

Generated-by: Claude Code (Opus 4.7) following the guidelines

``_load_logging_config`` called ``discover_remote_log_handler`` without
exception protection. A raise there propagated through
``load_remote_log_handler`` (which is called transitively from any
logger acquisition path) into the task lifecycle handler, crashing
the task with a non-obvious error.

Wrap discovery in try/except. On failure, emit a warning to the
dedicated ``airflow.logging.remote`` structlog logger so operators
relying on remote-log uploads still see the failure, and fall back to
"no remote handler" so the rest of the logging system initialises and
the task can run with local logs only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant