Skip to content

Fix before_send/transport dotted-path resolution in Task SDK Sentry c…#69685

Open
bujjibabukatta wants to merge 2 commits into
apache:mainfrom
bujjibabukatta:fix/#69464
Open

Fix before_send/transport dotted-path resolution in Task SDK Sentry c…#69685
bujjibabukatta wants to merge 2 commits into
apache:mainfrom
bujjibabukatta:fix/#69464

Conversation

@bujjibabukatta

Copy link
Copy Markdown
Contributor

Fix [sentry] before_send/transport dotted-path config never resolved to a callable in Task SDK

Problem

ConfiguredSentry.prepare_to_enrich_errors() in
task-sdk/src/airflow/sdk/execution_time/sentry/configured.py resolves the
before_send/transport dotted-path config options into real callables only
inside an else branch guarded by if sentry_config_opts:.

conf.getsection("sentry") always returns a non-empty dict (schema defaults
such as sentry_on are always present), so that if is always true and the
else branch — the only place before_send/transport are ever resolved via
conf.getimport() — is unreachable dead code.

As a result, a configured before_send/transport dotted path is passed to
sentry_sdk.init() as a raw string instead of a callable. sentry_sdk then
raises TypeError: 'str' object is not callable internally when trying to
invoke it, which it swallows via capture_internal_exceptions() — so every
Sentry event is silently dropped with no error surfaced to the user.

This is a regression from Airflow 2.x's airflow/sentry.py, where the
equivalent conf.getimport(...) calls ran unconditionally. The branching
structure changed when this was ported to the Task SDK in #57032, making the
resolution path unreachable.

Fix

Make before_send/transport resolution unconditional, matching 2.x
behavior, while preserving the existing DSN handling and the
UNSUPPORTED_SENTRY_OPTIONS warning.

Testing

  • Updated the three existing tests (test_prepare_to_enrich_errors,
    test_prepare_to_enrich_errors_with_executor_integration,
    test_custom_transport) that were asserting the unresolved dotted-path
    string
    was passed to sentry_sdk.init() — they now assert the resolved
    callable
    , which is effectively the regression test for this bug.
  • No behavior change when before_send/transport aren't configured
    (test_minimum_config still passes unchanged).

closes: #69464

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.

Sentry before_send/transport dotted-path config never resolved to a callable in Task SDK (silently drops all events)

1 participant