<#1146 fix: wrap RuntimeError at user-module impor...
# flyte-github
a
#1146 fix: wrap RuntimeError at user-module import as ModuleLoadError Pull request opened by EngHabu Problem A user or plugin module that raises a plain
RuntimeError
at import time leaks into the SDK's Sentry project as if it were an SDK crash. The module loader's two
except
clauses already wrap
(ImportError, SyntaxError, NameError, AttributeError, TypeError, ValueError, KeyError)
raised during user-code import as
ModuleLoadError
— a
RuntimeUserError
subclass already filtered by
flyte/_sentry.py:_is_user_error
. But
RuntimeError
was not in the tuple, so it bubbled straight through. Fix Add
RuntimeError
to both
except
clauses in
src/flyte/_utils/module_loader.py
(single-file path and directory path).
flyte.errors.ModuleLoadError
is still caught first, so SDK-wrapped load errors keep their existing behavior. Closes • FLYTE-SDK-46 —
RuntimeError: union.sandbox default environments are unavailable — install union-sandbox[deploy]
raised at import of
union/sandbox/task/_server.py
.
fixes FLYTE-SDK-46
Tests • Extended the
test_load_python_modules_single_file_wraps_user_code_errors
parametrization with
RuntimeError
. • Added
test_load_python_modules_single_file_wraps_runtime_error
reproducing the FLYTE-SDK-46 shape (a module that raises the union.sandbox message at top level), asserting
ModuleLoadError
wraps it with the file path and original type. 🤖 Generated with Claude Code flyteorg/flyte-sdk