Bug #34729
closedrepositories/import_uploads API endpoint do require two mandatory parameters
Description
Description of problem:
Sat 6.10 APIdoc at https://your-sat610/apidoc/v2/repositories/import_uploads.html
say that
uploads[checksum]
uploads[name]
are optional. BUT both are mandatory.
Please either update the APIdoc or fix the product per APIdoc (fixing the product is imho better - why the API insists on filename or its checksum, if we uniquely identified it via upload_url? Well, checksum can be required for the sake of ensuring integrity/validity of uploaded content, but filename..?)
Version-Release number of selected component (if applicable):
Sat 6.10.3
How reproducible:
100%
Steps to Reproduce:
1. Use below script with customized Sat credentials to upload a package to a repository. It is a fixed procedure per https://access.redhat.com/documentation/en-us/red_hat_satellite/6.10/html-single/api_guide/index#sect-API_Guide-Uploading_Content_to_the_Satellite_Server (fixed: see relevant BZ)
Usage:
./upload_package_to_repo.sh REPOID /path/to/package.rpm
-----8<-----
if [ $# -lt 2 ]; then
echo "too few arguments"
exit
fi
repoid=${1}
package=${2}
pkgname=${package##*/}
creds=admin:redhat
saturl=$(hostname -f)
size=$(wc -c $package | awk '{ print $1}')
checksum=$(sha256sum $package | awk '{ print $1}')
upload_url=$(curl --header "Accept:application/json" \
--header "Content-Type:application/json" \
--request POST --insecure --user $creds \
--data "{\"size\": ${size}}" \
https://${saturl}/katello/api/repositories/${repoid}/content_uploads | cut -d\" -f4 )
curl --header "Accept:application/json" \
--header "Content-Type:multipart/form-data" \
--request PUT --insecure --user $creds \
--data-urlencode "content@${package}" \
--data-urlencode offset=0 \
--data-urlencode size=${size} \
https://${saturl}/katello/api/repositories/${repoid}/content_uploads/${upload_url}
curl --header "Accept:application/json" \
--header "Content-Type:application/json" \
--request PUT --insecure \
--user $creds \
--data "{\"uploads\":[{\"id\": \"${upload_url}\", \"checksum\": \"${checksum}\", \"name\": \"${pkgname}\"}]}" \
https://${saturl}/katello/api/repositories/${repoid}/import_uploads
-----8<-----
2. Use the script to upload a package
3. From the latest curl method, remove either
\"checksum\": \"${checksum}\"
or
\"name\": \"${pkgname}\"
attributes and retry.
Actual results:
2. Package upload succeeds.
3. Removing checksum, Sat raises
Katello::HttpErrors::BadRequest: no implicit conversion of nil into String
and removing name, Sat raises
ArgumentError: Missing the required parameter 'relative_path' when calling ContentPackagesApi.create
error and upload fails.
Expected results:
Align APIdoc mandatory parameters with reality.
Updated by The Foreman Bot over 2 years ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/Katello/katello/pull/10049 added
Updated by The Foreman Bot over 2 years ago
- Fixed in Releases Katello 4.5.0 added
Updated by Chris Roberts over 2 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset katello|2d288ff1a6ae471119d6810c9abe9ce555f97971.