]> git.ipfire.org Git - pbs.git/commitdiff
builds: Update API error response codes
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 20 Oct 2023 09:49:05 +0000 (09:49 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 20 Oct 2023 09:49:05 +0000 (09:49 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/web/builds.py

index 0cd35bd827eaf306125309ae322f437d8de4d422..be8bef0d173d70aab70cb45da3ccfe25a3398f7c 100644 (file)
@@ -1,5 +1,6 @@
 #!/usr/bin/python
 
+import errno
 import tornado.web
 
 from ..errors import NoSuchDistroError
@@ -15,13 +16,13 @@ class APIv1IndexHandler(base.APIMixin, base.BaseHandler):
        @base.negotiate
        async def post(self):
                # Fetch the upload
-               upload = self.get_argument_upload("upload_id")
+               upload = self.get_argument_upload("upload")
                if not upload:
                        raise tornado.web.HTTPError(404, "Could not find upload")
 
                # Check permissions of the upload
                if not upload.has_perm(self.current_user):
-                       raise tornado.web.HTTPError(403, "No permission for using upload %s" % upload)
+                       raise base.APIError(errno.ENOPERM, "No permission for using upload %s" % upload)
 
                # Fetch the repository
                repo_name = self.get_argument("repo", None)
@@ -37,13 +38,13 @@ class APIv1IndexHandler(base.APIMixin, base.BaseHandler):
                        # If the distribution that is coded into the package could not be found,
                        # we will send that error to the user...
                        except NoSuchDistroError as e:
-                               raise tornado.web.HTTPError(404, "Could not find distribution: %s" % e)
+                               raise base.APIError(errno.ENOENT, "Could not find distribution: %s" % e)
 
                        try:
                                # Find the repository
                                repo = self.current_user.get_repo(package.distro, repo_name)
                                if not repo:
-                                       raise tornado.web.HTTPError(404, "Could not find repository")
+                                       raise base.APIError(errno.ENOENT, "Could not find repository")
 
                                # Create a new build
                                build = await self.backend.builds.create(repo, package,