The publish endpoint assumes that the uploaded file was base64 encoded.
As ansible-galaxy clients go, 2.10 and higher do base64 encode the tarball, but 2.9 does not, it sends the raw bytes.
This causes a traceback:
Traceback (most recent call last):
File "/home/briantist/code/galactory/.venv/lib/python3.8/site-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/home/briantist/code/galactory/.venv/lib/python3.8/site-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/briantist/code/galactory/.venv/lib/python3.8/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/home/briantist/code/galactory/.venv/lib/python3.8/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/home/briantist/code/galactory/galactory/api/v3/collections.py", line 338, in publish
with _chunk_to_temp(Base64IO(file)) as tmp:
File "/home/briantist/code/galactory/galactory/utilities.py", line 177, in _chunk_to_temp
for chunk in it:
File "/home/briantist/code/galactory/galactory/utilities.py", line 168, in <lambda>
it = iter(lambda: fsrc.read(chunk_size), b'') if iterator is None else iterator(chunk_size)
File "/home/briantist/code/galactory/.venv/lib/python3.8/site-packages/base64io/__init__.py", line 298, in read
results.write(base64.b64decode(data))
File "/usr/lib/python3.8/base64.py", line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
I don't have a particular interest in supporting a client as old as 2.9, especially since you can still use a newer version to publish your collections even if you are still using 2.9 for some reason.
However, both the v2 and v3 galaxy protocols seem to accept either form, even if that's not documented, so it seems like galactory should support it too.
The publish endpoint assumes that the uploaded file was base64 encoded.
As
ansible-galaxy
clients go, 2.10 and higher do base64 encode the tarball, but 2.9 does not, it sends the raw bytes.This causes a traceback:
I don't have a particular interest in supporting a client as old as 2.9, especially since you can still use a newer version to publish your collections even if you are still using 2.9 for some reason.
However, both the v2 and v3 galaxy protocols seem to accept either form, even if that's not documented, so it seems like galactory should support it too.
Another reason to support this is for easier usage with other clients, like
curl
. Even the docs for the new v3 galaxy show a curl example exclusively, without base64 encoding: https://ansible.readthedocs.io/projects/galaxy-ng/en/latest/community/api_v3/#upload-a-collection