Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1710555

Summary: rest-api endpoint /katello/api/v2/environments with sort_by=id no longer works with 6.5 (but did with 6.3 and 6.4)
Product: Red Hat Satellite Reporter: Reartes Guillermo <greartes>
Component: Lifecycle EnvironmentsAssignee: James Jeffers <jjeffers>
Status: CLOSED ERRATA QA Contact: Perry Gagne <pgagne>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.5.0CC: apatel, egolov
Target Milestone: 6.7.0Keywords: Regression, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-3.14.0-0.4.rc2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-14 13:24:30 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:

Description Reartes Guillermo 2019-05-15 18:46:18 UTC
Description of problem:

I previously used the rest-api endpoint "/katello/api/v2/environments" with sort_by=id. It works with 6.4 and 6.3.
 
After the upgrade to 6.5 i noticed i was not getting the lifecycle environmens list. After some diagnosis i noticed that the endpoint changed behaviour.

I use the endpoint in a ruby script that i wrote, but i put regular CURLs on the bugreport.

Was "sort_by=id" removed?

Version-Release number of selected component (if applicable):
6.5.0

How reproducible:
always

Steps to Reproduce:
This used to work for Sat 6.4 and 6.3, it does not work with Sat 6.5
$ curl -k -u admin:redhat01 -X GET https://sixthsat2.example.com/katello/api/v2/environments?page=1\&sort_by=id\&per_page=10\&sort_order=ASC
{"total":0,"subtotal":0,"page":null,"per_page":null,"error":"the field 'id' in the order statement is not valid field for search","search":null,"sort":{"by":"id","order":"ASC"},"results":[]}

Actual results:
This used to work for Sat 6.4 and 6.3, it does not work with Sat 6.5
$ curl -k -u admin:redhat01 -X GET https://sixthsat2.example.com/katello/api/v2/environments?page=1\&sort_by=id\&per_page=10\&sort_order=ASC
{"total":0,"subtotal":0,"page":null,"per_page":null,"error":"the field 'id' in the order statement is not valid field for search","search":null,"sort":{"by":"id","order":"ASC"},"results":[]}

Expected results:

Workarounds:
a) remove sorting:
$ curl -k -u admin:redhat01 -X GET https://sixthsat2.example.com/katello/api/v2/environments?page=1\&per_page=10\&sort_order=ASC
b) sory by name instead. (But sorting by name does work. I no longer have a Sat 6.4 to test ATM.)
$ curl -k -u admin:redhat01 -X GET https://sixthsat2.example.com/katello/api/v2/environments?page=1\&sort_by=name\&per_page=10\&sort_order=ASC

Additional info:
I re-checked the apidoc but i found no help on "valid" sort_by values. So i cannot know if this is intentional or just a bug.
On the APIDOC:
 sort_by -> optional "Field to sort the results on"
 Validations: String
And no more info.

Comment 4 Perry Gagne 2019-12-02 20:35:54 UTC
Verified fix in Sat 6.7 snap 4. 

1. Created a number of lifecycle environments
2. curl -k -u admin:password -X GET "https://satellite.example.com/katello/api/v2/environments?page=1&sort_by=id&per_page=10&sort_order=ASC"

The result was all the lifecycle environments, sorted by id. Also tried it with out sort_by and got a (seemingly) random order.

Comment 7 errata-xmlrpc 2020-04-14 13:24:30 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, 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-2020:1454