Skip to content

Client file uploads fail if api-url has a trailing slash

debusine setup puts a trailing / on api-url in the client configuration. This causes file uploads to fail (this is via dput-ng, but the normal client should behave the same way):

Traceback (most recent call last):
  File "/usr/bin/dput", line 129, in <module>
    upload_package(changes, args)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/dput/uploader.py", line 343, in invoke_dput
    obj.upload_file(path)
    ~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3/dist-packages/debusine/client/dput_ng/uploader.py", line 55, in upload_file
    self.debusine.upload_artifact(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        artifact, workspace=self.workspace
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3/dist-packages/debusine/client/debusine.py", line 376, in upload_artifact
    self.upload_files(
    ~~~~~~~~~~~~~~~~~^
        artifact_response.id,
        ^^^^^^^^^^^^^^^^^^^^^
        files_to_upload,
        ^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3/dist-packages/debusine/client/debusine.py", line 352, in upload_files
    file_uploader.upload(local_path, url)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/debusine/client/file_uploader.py", line 182, in upload
    success = self._upload_file(
        file, os.stat(file_path).st_size, url
    )
  File "/usr/lib/python3/dist-packages/debusine/client/file_uploader.py", line 140, in _upload_file
    raise UnexpectedStatusCodeError(r)
debusine.client.file_uploader.UnexpectedStatusCodeError: Client HTTP PUT https://debusine.debian.net/api//1.0/artifact/1546890/files/python-redis_5.2.1-1.debian.tar.xz/ with Content-Range bytes */7424 Received unexpected status code: 404 Response body:
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>404 Not Found</title>
    </head>
    <body>
        <h1>404 Not Found</h1>

    </body>
</html>

Looks like Debusine._url_for_file_in_artifact should use self.api_url rather than composing it for itself.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information