potiuk opened a new pull request, #67505: URL: https://github.com/apache/airflow/pull/67505
In `ConfiguredSentry.enrich_errors`, `prepare_to_enrich_errors`, `add_tagging` and `add_breadcrumbs` ran either outside any try block (line 142, pre-fix) or inside the same try-block as the wrapped `run(...)`. An exception raised by any of them propagated through the wrapper, so: - A failure in non-critical Sentry instrumentation was indistinguishable from a real task failure. - The wrapped `run` never executed — instrumentation could effectively prevent the task from running. Reported as F-006 in the [`apache/tooling-agents` L3 task-sdk sweep `0920c77`](https://github.com/apache/tooling-agents/issues/24). ## Change Wrap each instrumentation step (`prepare_to_enrich_errors`, `add_tagging`, `add_breadcrumbs`) in its own `try/except` and log a structured warning on failure (`sentry_prepare_failed`, `sentry_add_tagging_failed`, `sentry_add_breadcrumbs_failed`). The wrapped `run` still runs inside `sentry_sdk.new_scope` and its exceptions are captured via `sentry_sdk.capture_exception(e)` and re-raised — that path is unchanged. ## Test plan - [x] `test_enrich_errors_isolates_instrumentation_from_task_run` (parametrised across all three instrumentation steps) — asserts (a) the wrapped `run()` still executes when each step raises, (b) the structured warning is emitted on the task log. - [x] `test_enrich_errors_captures_and_reraises_task_failure` — asserts the wrapped-run failure path is unchanged: `sentry_sdk.capture_exception` is called, exception re-raised. - [x] `prek run ruff` clean. - [x] `prek run mypy-task-sdk` clean. - [x] Full `test_sentry.py` suite: 10 passed. --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Claude Code (Opus 4.7) Generated-by: Claude Code (Opus 4.7) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- 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]
