Fix before_send/transport dotted-path resolution in Task SDK Sentry c…#69685
Open
bujjibabukatta wants to merge 2 commits into
Open
Fix before_send/transport dotted-path resolution in Task SDK Sentry c…#69685bujjibabukatta wants to merge 2 commits into
bujjibabukatta wants to merge 2 commits into
Conversation
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.
Fix
[sentry] before_send/transportdotted-path config never resolved to a callable in Task SDKProblem
ConfiguredSentry.prepare_to_enrich_errors()intask-sdk/src/airflow/sdk/execution_time/sentry/configured.pyresolves thebefore_send/transportdotted-path config options into real callables onlyinside an
elsebranch guarded byif sentry_config_opts:.conf.getsection("sentry")always returns a non-empty dict (schema defaultssuch as
sentry_onare always present), so thatifis always true and theelsebranch — the only placebefore_send/transportare ever resolved viaconf.getimport()— is unreachable dead code.As a result, a configured
before_send/transportdotted path is passed tosentry_sdk.init()as a raw string instead of a callable.sentry_sdkthenraises
TypeError: 'str' object is not callableinternally when trying toinvoke it, which it swallows via
capture_internal_exceptions()— so everySentry event is silently dropped with no error surfaced to the user.
This is a regression from Airflow 2.x's
airflow/sentry.py, where theequivalent
conf.getimport(...)calls ran unconditionally. The branchingstructure changed when this was ported to the Task SDK in #57032, making the
resolution path unreachable.
Fix
Make
before_send/transportresolution unconditional, matching 2.xbehavior, while preserving the existing DSN handling and the
UNSUPPORTED_SENTRY_OPTIONSwarning.Testing
test_prepare_to_enrich_errors,test_prepare_to_enrich_errors_with_executor_integration,test_custom_transport) that were asserting the unresolved dotted-pathstring was passed to
sentry_sdk.init()— they now assert the resolvedcallable, which is effectively the regression test for this bug.
before_send/transportaren't configured(
test_minimum_configstill passes unchanged).closes: #69464