Bug 1710555 - 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)
Summary: rest-api endpoint /katello/api/v2/environments with sort_by=id no longer work...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Lifecycle Environments
Version: 6.5.0
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: 6.7.0
Assignee: James Jeffers
QA Contact: Perry Gagne
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-05-15 18:46 UTC by Reartes Guillermo
Modified: 2020-04-14 13:24 UTC (History)
2 users (show)

Fixed In Version: tfm-rubygem-katello-3.14.0-0.4.rc2
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-14 13:24:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 28185 0 Normal Closed 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) 2020-05-20 09:27:33 UTC
Red Hat Product Errata RHSA-2020:1454 0 None None None 2020-04-14 13:24:42 UTC

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


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