Bug 2228820

Summary: ISE when incorrect content-type used for organization creation through API
Product: Red Hat Satellite Reporter: Lukáš Hellebrandt <lhellebr>
Component: Organizations and LocationsAssignee: satellite6-bugs <satellite6-bugs>
Status: NEW --- QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.14.0CC: rlavi
Target Milestone: UnspecifiedKeywords: 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: 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
foreman-tail.txt none

Description Lukáš Hellebrandt 2023-08-03 10:53:49 UTC
Description of problem:
When I use an API call to create an organization and I specify an existing, but incorrect content-type (or I don't specify any at all), the call returns 500 Internal Server Error.

Version-Release number of selected component (if applicable):
Reproduced on Sat 6.14 snap 9.0, 10.0, but not 8.0.

How reproducible:
Deterministic

Steps to Reproduce:
1. # curl -uadmin:changeme -H 'Content-Type: application/json' -X POST https://$(hostname)/api/organizations -d '{"organization": {"name": "test1"}}'
{"select_all_types":[],"description":null,"created_at":"2023-08-03 10:51:04 UTC"
[...]
2. # curl -uadmin:changeme -H 'Content-Type: text/html' -X POST https://$(hostname)/api/organizations -d '{"organization": {"name": "test2"}}'
{
  "error": {"message":"Internal Server Error: the server was unable to finish the request. This may be caused by unavailability of some required service, incorrect API call or a server-side bug. There may be more information in the server's logs."}
}
3. # curl -uadmin:changeme -H 'Content-Type: text/html' -X POST https://$(hostname)/api/locations -d '{"location": {"name": "test3"}}'
{
  "error": {"message":"Media type in 'Content-Type: text/html' is unsupported in API v2 for POST and PUT requests. Please use 'Content-Type: application/json'."}
}

Actual results:
For correct content-type, the organization is created. For incorrect type on a location endpoint, a location is not created and the error is handled correctly. For incorrect type on an organization endpoint, ISE happens.

Expected results:
The same behavior as for locaiton.

Additional info:
Traceback attached.

Comment 1 Lukáš Hellebrandt 2023-08-03 10:55:57 UTC
Created attachment 1981466 [details]
foreman-tail.txt

The error is:

Backtrace for 'Action failed' error (NoMethodError): undefined method `[]=' for nil:NilClass

Comment 2 Lukáš Hellebrandt 2023-08-03 11:15:34 UTC
Also reproduced on Sat 6.13.0