fix: wrap any user-module import exception as ModuleLoadError#1168
Open
EngHabu wants to merge 2 commits into
Open
fix: wrap any user-module import exception as ModuleLoadError#1168EngHabu wants to merge 2 commits into
EngHabu wants to merge 2 commits into
Conversation
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
92021da to
8319963
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
User modules can raise arbitrary third-party exceptions at import time that don't inherit from
RuntimeError/ImportError/ etc. The clearest example:google.api_core.exceptions.RetryError(parent:Exception) is raised when a user's module-top-level code calls Google Secret Manager and gcloud credentials have expired. The SDK's import loop only catches a narrow tuple —(ImportError, SyntaxError, NameError, AttributeError, TypeError, ValueError, KeyError, RuntimeError)— so anything else escapes and lands in Sentry as if it were an SDK bug.PRs #1094 / #1134 / #1146 widened that tuple incrementally. Time to finish the job: anything raised inside
importlib.import_module(<user-module>)is, by definition, an error in the user's code or its third-party imports.Fix
Widen both
exceptclauses insrc/flyte/_utils/module_loader.py(file-path branch and directory branch) from the explicit tuple to plainexcept Exception. Wrap asflyte.errors.ModuleLoadError(aRuntimeUserErroralready filtered byflyte/_sentry.py:_is_user_error) so deploy surfaces an actionable error and Sentry stops receiving user import-time crashes.Closes
google.api_core.exceptions.RetryError: Timeout of 60.0s exceededraised from the user'sgsm_secrets.set_secrets_as_dict_gcp_flyteduring user-module import (expired gcloud creds —gcloud auth application-default login).fixes FLYTE-SDK-39Tests
Exceptionsubclass at import time is captured as a load failure (or re-raised asModuleLoadErrorfor the file-path branch).