<#1152 fix: filter ConnectError(INTERNAL) upstream...
# flyte-github
a
#1152 fix: filter ConnectError(INTERNAL) upstream 5xx / connection-refused from Sentry Pull request opened by EngHabu Summary The rust backend's nginx returns 502/503/504/500 when overloaded or restarting, and the backend's own outbound calls to its object store occasionally fail with connection refused. Both surface to the SDK as:
Copy code
ConnectError(INTERNAL, desc=<raw upstream body>)
  → RuntimeSystemError("Failed to ... : <body>")
and leak into Sentry as if they were SDK crashes. They aren't — the system is upstream of the SDK and the SDK can't recover.
INTERNAL
is intentionally not in
_USER_ACTIONABLE_CONNECT_CODES
(#1137) because that code is also where real backend/SDK bugs land. So we can't filter on code alone — we need to distinguish the upstream-infra flavor by message body. Change New
_is_upstream_infra_internal_error
in
src/flyte/_sentry.py
, walked over the existing cause chain alongside
_is_user_actionable_connect_error
and
_is_user_environment_oserror
. It matches
ConnectError(INTERNAL)
only when the message body contains one of: •
502 Bad Gateway
•
503 Service Unavailable
•
504 Gateway Timeout
•
Internal Server Error
(HTTP 500 from upstream nginx) •
connection refused
(rust backend's outbound dependency) Bare
INTERNAL
("backend panicked", serialization mismatches, anything without a recognized upstream-infra signature) still reaches Sentry — a regression-guard test covers that, paired with the existing
test_capture_exception_still_reports_connect_error_internal
. Sentry issues closed • FLYTE-SDK-4H —
Failed to create run: failed to upload inputs: rpc error: code = Internal desc = ... 502 Bad Gateway
(12 events, escalating) • FLYTE-SDK-4K —
Upload failed for ... rpc error: code = Internal ... 502 Bad Gateway
• FLYTE-SDK-4J —
Failed to write data ... PutObject ... dial tcp 10.43.94.220:9000: connect: connection refused
(rust backend can't reach rustfs) • FLYTE-SDK-43 —
SelectCluster failed for operation=1: Internal Server Error
(HTTP 500 upstream)
fixes FLYTE-SDK-4H
fixes FLYTE-SDK-4J
fixes FLYTE-SDK-4K
fixes FLYTE-SDK-43
Test plan • Parametrized
test_capture_exception_skips_connect_error_internal_upstream_5xx
— 502/503/504/500 bodies all filtered. • New
test_capture_exception_skips_connect_error_internal_connection_refused
— the rustfs PutObject connection-refused chain filtered. • New
test_capture_exception_still_reports_connect_error_internal_without_upstream_signature
— regression guard;
ConnectError(INTERNAL, "backend panicked: serialization mismatch")
still reaches Sentry. • All 30 tests in
tests/flyte/test_sentry.py
pass (was 25). •
make fmt
clean. 🤖 Generated with Claude Code flyteorg/flyte-sdk