This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
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 2250181 - API endpoint "/katello/api/repositories/:id/upload_content " not accepting calls from the client
Summary: API endpoint "/katello/api/repositories/:id/upload_content " not accepting ca...
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Repositories
Version: 6.13.6
Hardware: All
OS: All
unspecified
medium
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Satellite QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-11-16 20:42 UTC by Waldirio M Pinheiro
Modified: 2024-06-06 16:36 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2024-06-06 16:36:27 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker   SAT-21353 0 None Migrated None 2024-06-06 16:36:26 UTC

Description Waldirio M Pinheiro 2023-11-16 20:42:54 UTC
Description of problem:
API endpoint "/katello/api/repositories/:id/upload_content" it's not accepting the call when doing it via CLI (curl, python, ruby, etc)

Version-Release number of selected component (if applicable):
6.13.z

How reproducible:
100%

Steps to Reproduce:
1. Create the json file
2. Run the curl command
3.

Actual results:
We will be able to see the error below
---
{
    "displayMessage": "undefined method `path' for #<String:0x00007ff0669b76d0>\nDid you mean?  pathmap",
    "errors": [
        "undefined method `path' for #<String:0x00007ff0669b76d0>\nDid you mean?  pathmap"
    ]
}
---

Expected results:
To upload the file in a single shot

Additional info:
We know that we have already a second endpoint, "/katello/api/repositories/:repository_id/content_uploads", which will be able to upload the file as well.

Ps.: Note that this endpoint is special and it should be used ONLY for the webUI, which will apply some additional information and will make it work.

Comment 1 Waldirio M Pinheiro 2023-11-16 20:50:23 UTC
Hello,

Let me describe the whole scenario here, based on the docs, the required information are id and content, as we can see below
---
# cat file.json 
{
"id":22,
"content": ["/root/wally/katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm"]
}
---

With that, we can call the curl passing all the parameters
---
# curl -s -H 'Content-Type: application/json' -H 'Accept:application/json' -X POST -u admin:pass_here -d @file.json https://$(hostname)/katello/api/repositories/22/upload_content | json_reformat
{
    "displayMessage": "undefined method `path' for #<String:0x00007ff0669b76d0>\nDid you mean?  pathmap",
    "errors": [
        "undefined method `path' for #<String:0x00007ff0669b76d0>\nDid you mean?  pathmap"
    ]
}
---

Note. 22 is the id of the custom repo that was created.


Adding some audit in the code "/usr/share/gems/gems/katello-4.7.0.31/app/controllers/katello/api/v2/repositories_controller.rb", we can see the output below when executing the curl command
---
Nov 16 20:36:52 wallsat613 foreman[104690]: AUDIT: HERE .....
Nov 16 20:36:52 wallsat613 foreman[104690]: AUDIT: params - {"id"=>"22", "content"=>["/root/wally/katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm"], "api_version"=>"v2", "controller"=>"katello/api/v2/repositories", "action"=>"upload_content", "repository"=>{"id"=>22}}
Nov 16 20:36:52 wallsat613 foreman[104690]: AUDIT: params[:content] - ["/root/wally/katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm"]
Nov 16 20:36:52 wallsat613 foreman[104690]: AUDIT: simple = ["/root/wally/katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm"]
Nov 16 20:36:52 wallsat613 foreman[104690]: AUDIT: complete = ["/root/wally/katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm"]
---

However, when doing it via webUI, we can see a different information. Here, the upload worked as expected.
---
Nov 16 20:21:07 wallsat613 foreman[104690]: AUDIT: HERE .....
Nov 16 20:21:07 wallsat613 foreman[104690]: AUDIT: params - {"content"=>[#<ActionDispatch::Http::UploadedFile:0x00007ff066d20ec0 @tempfile=#<Tempfile:/tmp/RackMultipart20231116-104690-10pducw.rpm>, @original_filename="katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm", @content_type="application/x-rpm", @headers="Content-Disposition: form-data; name=\"content[]\"; filename=\"katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm\"\r\nContent-Type: application/x-rpm\r\n">], "authenticity_token"=>"xLgPbyCG1zH83nvomUgd0Tz6RgtJR7Snufj8f/cnWJx8DAYAl0DOFl38Qv0+5lySfcv2NPu/H1mp8leWa9Q5+A==", "api_version"=>"v2", "controller"=>"katello/api/v2/repositories", "action"=>"upload_content", "id"=>"22"}
Nov 16 20:21:07 wallsat613 foreman[104690]: AUDIT: params[:content] - [#<ActionDispatch::Http::UploadedFile:0x00007ff066d20ec0 @tempfile=#<Tempfile:/tmp/RackMultipart20231116-104690-10pducw.rpm>, @original_filename="katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm", @content_type="application/x-rpm", @headers="Content-Disposition: form-data; name=\"content[]\"; filename=\"katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm\"\r\nContent-Type: application/x-rpm\r\n">]
Nov 16 20:21:07 wallsat613 foreman[104690]: AUDIT: simple = [#<ActionDispatch::Http::UploadedFile:0x00007ff066d20ec0 @tempfile=#<Tempfile:/tmp/RackMultipart20231116-104690-10pducw.rpm>, @original_filename="katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm", @content_type="application/x-rpm", @headers="Content-Disposition: form-data; name=\"content[]\"; filename=\"katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm\"\r\nContent-Type: application/x-rpm\r\n">]
Nov 16 20:21:07 wallsat613 foreman[104690]: AUDIT: complete = [#<ActionDispatch::Http::UploadedFile:0x00007ff066d20ec0 @tempfile=#<Tempfile:/tmp/RackMultipart20231116-104690-10pducw.rpm>, @original_filename="katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm", @content_type="application/x-rpm", @headers="Content-Disposition: form-data; name=\"content[]\"; filename=\"katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm\"\r\nContent-Type: application/x-rpm\r\n">]
Nov 16 20:21:07 wallsat613 foreman[104690]: AUDIT: filepaths - [{:path=>"/tmp/RackMultipart20231116-104690-10pducw.rpm", :filename=>"katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm"}]
---


Which led us to one question at this moment. Or we can add an information on the API page telling that this endpoint it's not supposed to be used by the customer/end user or that we can improve this endpoint in order to be able to accept external calls, like curl, python, ruby, etc.

Please, feel free to share your point of view.

Thank you!
Waldirio

Comment 2 Waldirio M Pinheiro 2023-11-21 19:07:00 UTC
Hello all,

Just adding some additional info



---
[root@wallsat613 wally]# curl -s -H 'Accept:application/json' -X POST -u admin:redhat -F "content=@/root/wally/katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm" https://$(hostname)/katello/api/repositories/22/upload_content | json_reformat
{
    "status": "success",
    "filenames": [
        "katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm"
    ]
}
---

---
Nov 21 18:48:02 wallsat613 foreman[104667]: AUDIT: HERE .....
Nov 21 18:48:02 wallsat613 foreman[104667]: AUDIT: params - {"content"=>#<ActionDispatch::Http::UploadedFile:0x00007ff0666b1170 @tempfile=#<Tempfile:/tmp/RackMultipart20231121-104667-1thw90q.rpm>, @original_filename="katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"content\"; filename=\"katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm\"\r\nContent-Type: application/octet-stream\r\n">, "api_version"=>"v2", "controller"=>"katello/api/v2/repositories", "action"=>"upload_content", "id"=>"22"}
Nov 21 18:48:02 wallsat613 foreman[104667]: AUDIT: params[:content] - #<ActionDispatch::Http::UploadedFile:0x00007ff0666b1170>
Nov 21 18:48:02 wallsat613 foreman[104667]: AUDIT: simple = [#<ActionDispatch::Http::UploadedFile:0x00007ff0666b1170 @tempfile=#<Tempfile:/tmp/RackMultipart20231121-104667-1thw90q.rpm>, @original_filename="katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"content\"; filename=\"katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm\"\r\nContent-Type: application/octet-stream\r\n">]
Nov 21 18:48:02 wallsat613 foreman[104667]: AUDIT: complete = [#<ActionDispatch::Http::UploadedFile:0x00007ff0666b1170 @tempfile=#<Tempfile:/tmp/RackMultipart20231121-104667-1thw90q.rpm>, @original_filename="katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"content\"; filename=\"katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm\"\r\nContent-Type: application/octet-stream\r\n">]
Nov 21 18:48:02 wallsat613 foreman[104667]: AUDIT: filepaths - [{:path=>"/tmp/RackMultipart20231121-104667-1thw90q.rpm", :filename=>"katello-ca-consumer-wallsat613.d.sysmgmt.cee.redhat.com-1.0-1.noarch.rpm"}]
---



Waldirio

Comment 3 Eric Helms 2024-06-06 16:36:27 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


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