[PATCH dlrepo] views: catch exception on invalid fmt name
Export this patch
Attempting to upload to a invalid format name (name starting with a
"." or containing a "/") resulted in error "500 Internal Server
Error". Let's catch the exception to get error "404: Not Found"
instead.
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
---
Acked-by: Robin Jarry <robin@jarry.cc>
Applied, thanks.
To git@git.sr.ht:~rjarry/dlrepo
a1b083dddcf5..01ffaabe716d main -> main
dlrepo/views/artifact.py | 2 + -
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlrepo/views/artifact.py b/dlrepo/views/artifact.py
index dcd40ca992d2..e7dc1bcef067 100644
--- a/dlrepo/views/artifact.py
+++ b/dlrepo/views/artifact.py
@@ -50,9 +50,9 @@ class ArtifactView(BaseView):
.get_tag(match["tag"], access_cb)
.get_job(match["job"])
)
+ fmt = job.get_format(match["format"])
except FileNotFoundError as e:
raise web.HTTPNotFound() from e
- fmt = job.get_format(match["format"])
if create:
if match["format"] == "container":
agent = self.request.headers.get("User-Agent", "")
--
2.39.2
Julien Floret <julien.floret@6wind.com> wrote:
dlrepo/patches/.build.yml: SUCCESS in 56s
[views: catch exception on invalid fmt name][0] from [~jfloret][1]
[0]: https://lists.sr.ht/~rjarry/dlrepo/patches/57990
[1]: mailto:julien.floret@6wind.com
✓ #1446339 SUCCESS dlrepo/patches/.build.yml https://builds.sr.ht/~rjarry/job/1446339