Bug 2129950

Summary: ISE when creating a CV with org_id specified as array
Product: Red Hat Satellite Reporter: Lukáš Hellebrandt <lhellebr>
Component: APIAssignee: Samir Jha <sajha>
Status: CLOSED ERRATA QA Contact: Peter Ondrejka <pondrejk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.12.0CC: egolov, pcreech, sajha
Target Milestone: 6.13.0Keywords: Regression, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-03 13:22:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
production.log none

Description Lukáš Hellebrandt 2022-09-26 19:09:01 UTC
Created attachment 1914454 [details]
production.log

Description of problem:
When creating a CV through API, I get ISE (log attached) when I specify organization ID as a list of IDs:

$ curl -uadmin:<password> -k -H "Content-Type:application/json" -H "Accept:application/json" -X POST https://<FQDN>/katello/api/v2/content_views -d '{"name": "test1", "organization_id": [1], "api_version": "v2", "content_view": {"name": "test1", "organization_id": [1]}}'

{"displayMessage":"undefined method `start_with?' for [1]:Array","errors":["undefined method `start_with?' for [1]:Array"]}

The part before ":Array" is the value specified for organization_id


Version-Release number of selected component (if applicable):
Reproduced with Sat 6.12.0 snap 12.0 AND 6.11.3

How reproducible:
Deterministic

Steps to Reproduce:
curl -uadmin:<password> -k -H "Content-Type:application/json" -H "Accept:application/json" -X POST https://<FQDN>/katello/api/v2/content_views -d '{"name": "test1", "organization_id": [1], "api_version": "v2", "content_view": {"name": "test1", "organization_id": [1]}}'

Actual results:
Traceback, error, no CV created

Expected results:
Either CV created with the specified organization or at least correctly handled error, no ISE

Comment 1 Lukáš Hellebrandt 2022-09-26 21:47:39 UTC
In 6.9.7, this error was handled correctly:
$ curl -uadmin:<password> -k -H "Content-Type:application/json" -H "Accept:application/json" -X POST https://<FQDN>/katello/api/v2/content_views -d '{"name": "test1", "organization_id": [1], "api_version": "v2", "content_view": {"name": "test1", "organization_id": [1]}}'
{"displayMessage":"Unfiltered params array: organization_id.","errors":["Unfiltered params array: organization_id."]}

6.10.1 does this, still ok but it's interesting how often the behavior changes:
$ curl -uadmin:<password> -k -H "Content-Type:application/json" -H "Accept:application/json" -X POST https://<FQDN>/katello/api/v2/content_views -d '{"name": "test1", "organization_id": [1], "api_version": "v2", "content_view": {"name": "test1", "organization_id": [1]}}'
{"message":"Organization with id [1] not found"}

In 6.11.0 snap 26.0, the behavior was already the same as reported.

Marking this as regression but this was regression in 6.11.0 against 6.10.

Comment 5 Lukáš Hellebrandt 2022-11-18 09:49:07 UTC
Hello Samir, ISE is never a correct response and if this is common, it is one more reason to handle the exception correctly. Also, this specific case with a CV is a regression. To make it sound less horrible, I agree that this is low severity. It can't be considered normal or ok though.

Comment 9 Lukáš Hellebrandt 2022-11-22 14:33:14 UTC
Why did automation do that? I don't think it had any specific reason, it was just so written that it passed an array. I've fixed it, this doesn't block automation.

Comment 11 Samir Jha 2022-12-02 14:03:26 UTC
Created redmine issue https://projects.theforeman.org/issues/35816 from this bug

Comment 12 Bryan Kearney 2022-12-03 16:03:17 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/35816 has been resolved.

Comment 13 Peter Ondrejka 2023-01-05 14:01:12 UTC
Verified on Satellite 6.13 snap 4, using steps from problem desc. The api call receives:

{"message":"Organization with id [1] not found"}(broker) 

The prodlog contains no ISE:

2023-01-05T08:56:03 [I|app|9e12714c] Started POST "/katello/api/v2/content_views" <ip> at 2023-01-05 08:56:03 -0500
2023-01-05T08:56:03 [I|app|9e12714c] Processing by Katello::Api::V2::ContentViewsController#create as JSON
2023-01-05T08:56:03 [I|app|9e12714c]   Parameters: {"name"=>"test1", "organization_id"=>[1], "api_version"=>"v2", "content_view"=>{"name"=>"test1", "organization_id"=>[1]}}
2023-01-05T08:56:03 [I|app|9e12714c] Authorized user admin(Admin User)
2023-01-05T08:56:03 [I|app|9e12714c] Filter chain halted as :authorize rendered or redirected
2023-01-05T08:56:03 [I|app|9e12714c] Completed 404 Not Found in 270ms (Views: 1.1ms | ActiveRecord: 29.8ms | Allocations: 13891)

Comment 16 errata-xmlrpc 2023-05-03 13:22:11 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.13 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-2023:2097