<#1078 fix: walk exception cause chain in Sentry u...
# flyte-github
a
#1078 fix: walk exception cause chain in Sentry user-error filter Pull request opened by EngHabu Summary
_upload_single_file
(and other call sites) wrap the underlying
ConnectError
/
AuthenticationError
/
RuntimeError("SelectCluster failed ...")
in a
RuntimeSystemError("Failed to get signed url ...")
. The outer
RuntimeSystemError
is not in `_is_user_error`'s set, so even though the chained cause is a user-facing problem (expired refresh token, expired device code, IDP rejection, transport timeout), the wrapped exception lands in Sentry as an unhandled SDK crash. Two changes: 1.
_iter_cause_chain
— walk
__cause__
/
__context__
with a
seen
set and a depth cap of 16 (cycle-safe, won't spin even if a downstream bug wires a cycle). 2.
_is_user_error
— classify against the cause chain rather than just the outermost exception, and add
AuthenticationError
/
AccessTokenNotFoundError
(
flyte.remote._client.auth.errors
) to the user-error set. This also makes the existing
DeploymentError
/
ImageBuildError
/
InitializationError
/ click filters robust to wrapping further up the stack. Sentry issues These all share the same outer title (
RuntimeSystemError: Failed to get signed url for ...
) but the chained cause varies — this PR filters them all out at the Sentry boundary: • FLYTE-SDK-2A — cause: `AuthenticationError`/`RuntimeError(invalid_grant ... refresh token expired)` • FLYTE-SDK-2P — cause:
AuthenticationError(device code has expired)
• FLYTE-SDK-29 — cause:
TimeoutError
/
ConnectError(Request timed out)
• FLYTE-SDK-31 — cause:
ConnectTimeout
FLYTE-SDK-2H
(cause: server-side validation
project_id.organization length must be at least 1
) is not classified as a user error by this change — it's a config gap on the user's side but the SDK should produce a clearer error before hitting the server. Tracked separately. Test plan • New tests in `tests/flyte/test_sentry.py`: • wrapped
AuthenticationError
3-deep chain (the exact shape from FLYTE-SDK-2P) is filtered • wrapped
AccessTokenNotFoundError
is filtered • wrapped
DeploymentError
(via
__cause__
) is filtered • unrelated
RuntimeError
still goes to Sentry (no regression on real crashes) • cycle in
__cause__
chain doesn't hang
_iter_cause_chain
• All 13 sentry tests pass •
make fmt
clean • Commit signed (
-s
) 🤖 Generated with Claude Code flyteorg/flyte-sdk