From 8afaedddba248a34a0bb175189f04cf1119034e6 Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Thu, 21 Dec 2023 10:38:58 +0100 Subject: [PATCH] fix(service): add proper error if a dataset can't be found (#3661) --- renku/ui/service/errors.py | 15 ++++++++++++++- renku/ui/service/views/error_handlers.py | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/renku/ui/service/errors.py b/renku/ui/service/errors.py index 961718bf9c..1504a89d5d 100644 --- a/renku/ui/service/errors.py +++ b/renku/ui/service/errors.py @@ -121,7 +121,7 @@ def _handle_sentry(self): sentry_target = sentry_url.netloc.split("@")[-1] # NOTE: sentry doesn't support a global search. A proper link would require the specific org sentry = f"{sentry_url.scheme }://{sentry_target}/organizations/sentry?query={sentry}" - except Exception: + except Exception: # nosec pass except KeyError as e: sentry = f"Unexpected error while reporting to Sentry: {str(e)}" @@ -348,6 +348,19 @@ def __init__(self, exception=None): super().__init__(exception=exception) +class UserDatasetsNotFoundError(ServiceError): + """Dataset couldn't be found in project.""" + + code = SVC_ERROR_USER + 133 + userMessage = ( + "The dataset doesn't exist in the project. Please check your inputs or create the target dataset first." + ) + devMessage = "The dataset couldn't be found in the project." + + def __init__(self, exception=None): + super().__init__(exception=exception) + + class UserOutdatedProjectError(ServiceError): """The operation can be done only after updating the target project.""" diff --git a/renku/ui/service/views/error_handlers.py b/renku/ui/service/views/error_handlers.py index 5cfab9e0bc..d56de3bbfc 100644 --- a/renku/ui/service/views/error_handlers.py +++ b/renku/ui/service/views/error_handlers.py @@ -28,6 +28,7 @@ AuthenticationError, DatasetExistsError, DatasetImageError, + DatasetNotFound, DockerfileUpdateError, GitCommandError, GitError, @@ -65,6 +66,7 @@ ProgramUpdateProjectError, ServiceError, UserDatasetsMultipleImagesError, + UserDatasetsNotFoundError, UserDatasetsUnlinkError, UserDatasetsUnreachableImageError, UserInvalidGenericFieldsError, @@ -368,6 +370,8 @@ def decorated_function(*args, **kwargs): if "".join(value) == "Field may not be null.": raise UserMissingFieldError(e, key) raise + except DatasetNotFound as e: + raise UserDatasetsNotFoundError(e) except DatasetExistsError as e: raise IntermittentDatasetExistsError(e) except RenkuException as e: