bujjibabukatta opened a new pull request, #69685:
URL: https://github.com/apache/airflow/pull/69685

   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


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to