Guard _load_logging_config when remote log handler discovery fails#67504
Open
potiuk wants to merge 1 commit into
Open
Guard _load_logging_config when remote log handler discovery fails#67504potiuk wants to merge 1 commit into
potiuk wants to merge 1 commit into
Conversation
``_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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_load_logging_configcalleddiscover_remote_log_handlerwithout exception protection. A raise there propagated throughload_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-agentsL3 task-sdk sweep0920c77.Change
Wrap
discover_remote_log_handlerin try/except. On failure, emit a warning to the dedicatedairflow.logging.remotestructlog logger (same logger PR #66571 uses forremote_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— patchesdiscover_remote_log_handlerto raiseImportError; asserts the warning lands with exc_info,_ActiveLoggingConfig.remote_task_log is None, andlogging_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 ruffclean.prek run mypy-task-sdkclean.test_log.pysuite passes.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.7) following the guidelines