Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2068454 - repositories/import_uploads API endpoint do require two mandatory parameters
Summary: repositories/import_uploads API endpoint do require two mandatory parameters
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Repositories
Version: 6.10.3
Hardware: x86_64
OS: Linux
high
medium
Target Milestone: 6.12.0
Assignee: Chris Roberts
QA Contact: Cole Higgins
URL:
Whiteboard:
Depends On:
Blocks: 2068453
TreeView+ depends on / blocked
 
Reported: 2022-03-25 11:17 UTC by Pavel Moravec
Modified: 2022-11-16 13:34 UTC (History)
7 users (show)

Fixed In Version: tfm-rubygem-katello-4.5.0.17-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-11-16 13:33:45 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 35567 0 Normal Ready For Testing repositories/import_uploads API endpoint do require two mandatory parameters 2022-09-26 20:12:27 UTC
Github Katello katello pull 10290 0 None open Fixes #35567 - For non docker uploads require name/checksum 2022-09-26 20:12:27 UTC
Red Hat Issue Tracker SAT-13134 0 None None None 2022-09-27 23:14:37 UTC
Red Hat Issue Tracker SAT-9307 0 None None None 2022-04-05 15:06:58 UTC
Red Hat Product Errata RHSA-2022:8506 0 None None None 2022-11-16 13:34:01 UTC

Description Pavel Moravec 2022-03-25 11:17:54 UTC
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.


Additional info:

Comment 1 Pavel Moravec 2022-03-25 11:19:56 UTC
See related doc bug https://bugzilla.redhat.com/show_bug.cgi?id=2068453 (as a "superset issue" of this APIdoc/product bug).

Comment 3 Pavel Moravec 2022-03-25 17:21:17 UTC
Hi Adam and Justin,
raising needinfo on you for your awareness due to the customer escallation behind / tight schedule for Sat upgrade.

Not sure if the problem is in repositories (Justin) or API (Adam), hence raising the needinfo to both.

Comment 4 Justin Sherrill 2022-03-25 18:44:08 UTC
API is too generic of a component, most bugs should not go there, so moved to repositories.  I'll dig a little big.

Comment 5 Justin Sherrill 2022-03-25 18:48:09 UTC
I agree, these parameters look required, we should mark them as such.

Comment 6 Bryan Kearney 2022-04-11 20:04:53 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34729 has been resolved.

Comment 13 errata-xmlrpc 2022-11-16 13:33:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.12 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:8506


Note You need to log in before you can comment on or make changes to this bug.