From cd8dd4a272328a388db9727bbc81a2d9886794dd Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Mon, 11 May 2020 13:52:38 -0400 Subject: [PATCH] Fix galaxy publish sha256 value format. (#67942) * Fix galaxy publish sha256 value format. The multipart/form content used for the body of the POST to /api/automation-hub/v3/collections was missing a newline before the line with the value of the sha256. automation-hub/galaxy/django skips the field entirely in that case and automation-hub code will use None for default to indicate that no sha256 is provided (an available option). Fixes ansible/galaxy-dev#246 * Add changelog fragment Co-authored-by: Matt Martz --- changelogs/fragments/67942-fix-galaxy-multipart.yml | 3 +++ lib/ansible/galaxy/api.py | 1 + 2 files changed, 4 insertions(+) create mode 100644 changelogs/fragments/67942-fix-galaxy-multipart.yml diff --git a/changelogs/fragments/67942-fix-galaxy-multipart.yml b/changelogs/fragments/67942-fix-galaxy-multipart.yml new file mode 100644 index 00000000000..bf756bdecc8 --- /dev/null +++ b/changelogs/fragments/67942-fix-galaxy-multipart.yml @@ -0,0 +1,3 @@ +bugfixes: +- ansible-galaxy - Fix ``multipart/form-data`` body to include extra CRLF + (https://github.com/ansible/ansible/pull/67942) diff --git a/lib/ansible/galaxy/api.py b/lib/ansible/galaxy/api.py index d8e863c61d6..b9de56d0592 100644 --- a/lib/ansible/galaxy/api.py +++ b/lib/ansible/galaxy/api.py @@ -435,6 +435,7 @@ class GalaxyAPI: form = [ part_boundary, b"Content-Disposition: form-data; name=\"sha256\"", + b"", to_bytes(secure_hash_s(data, hash_func=hashlib.sha256), errors='surrogate_or_strict'), part_boundary, b"Content-Disposition: file; name=\"file\"; filename=\"%s\"" % b_file_name,