From c8df9142e7018d9838769ab7f244d389e9b9a2ba Mon Sep 17 00:00:00 2001 From: Otavio Jacobi Date: Tue, 15 Oct 2024 12:07:31 -0300 Subject: [PATCH] release: throw in case of trying to get a release with an empty string uuid Change-type: patch --- balena/models/release.py | 3 +++ tests/functional/models/test_release.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/balena/models/release.py b/balena/models/release.py index b5859d3f..c9c83713 100644 --- a/balena/models/release.py +++ b/balena/models/release.py @@ -57,6 +57,9 @@ def get( if commit_or_id_or_raw_version is None: raise exceptions.ReleaseNotFound(commit_or_id_or_raw_version) + if len(commit_or_id_or_raw_version) == 0: + raise exceptions.InvalidParameter("UUID can not be empty") + if is_id(commit_or_id_or_raw_version): release = self.__pine.get( {"resource": "release", "id": commit_or_id_or_raw_version, "options": options} # type: ignore diff --git a/tests/functional/models/test_release.py b/tests/functional/models/test_release.py index 85c13005..658a6f4a 100644 --- a/tests/functional/models/test_release.py +++ b/tests/functional/models/test_release.py @@ -173,6 +173,9 @@ def test_06_get_release_by_resources(self): ) # type: ignore self.__expect_release_to_match_on_get(release, match) + with self.assertRaises(self.helper.balena_exceptions.InvalidParameter): + self.balena.models.release.get("") + def test_07_get_all_by_application(self): app_id = self.mc_app["app"]["id"] releases = self.balena.models.release.get_all_by_application(app_id)