Bug #21525
ISE on Errata API list call when using invalid sort by name
Description
Requesting Errata List Via API causes an ISE if an invalid sort column name is used.
Steps to Reproduce:
1. you might need to have som repos providing some errata synced.
2. curl -sku admin:changeme "https://<fqdn>/katello/api/v2/errata?order=cve%20DESC"
(or name)
Actual results:
PG::Error: ERROR: column katello_errata.name does not exist
Expected results:
Listing works with the correct ordering or atleast uses the Default Sort By when sorting similar to the way invalid sort order is handled.
$ curl -sku admin:changeme "https://<FQDN>/katello/api/v2/errata?order=name%20ASC" {"displayMessage":"PG::Error: ERROR: column katello_errata.name does not exist\nLINE 1: ....\"id\" FROM \"katello_content_views\"))))) ORDER BY \"katello_e...\n ^\n: SELECT \"katello_errata\".* FROM \"katello_errata\" WHERE \"katello_errata\".\"id\" IN (SELECT \"katello_repository_errata\".\"erratum_id\" FROM \"katello_repository_errata\" WHERE \"katello_repository_errata\".\"repository_id\" IN (SELECT \"katello_repositories\".\"id\" FROM \"katello_repositories\" WHERE (katello_repositories.id in (SELECT \"katello_repositories\".\"id\" FROM \"katello_repositories\" WHERE \"katello_repositories\".\"product_id\" IN (SELECT \"katello_products\".\"id\" FROM \"katello_products\")) or katello_repositories.id in (SELECT \"katello_repositories\".\"id\" FROM \"katello_repositories\" INNER JOIN \"katello_content_view_repositories\" ON \"katello_content_view_repositories\".\"repository_id\" = \"katello_repositories\".\"id\" WHERE \"katello_content_view_repositories\".\"content_view_id\" IN (SELECT \"katello_content_views\".\"id\" FROM \"katello_content_views\")) or katello_repositories.id in (SELECT \"katello_repositories\".\"id\" FROM \"katello_repositories\" INNER JOIN \"katello_content_view_versions\" ON \"katello_content_view_versions\".\"id\" = \"katello_repositories\".\"content_view_version_id\" WHERE \"katello_content_view_versions\".\"content_view_id\" IN (SELECT \"katello_content_views\".\"id\" FROM \"katello_content_views\"))))) ORDER BY \"katello_errata\".\"name\" ASC, katello_errata.id DESC LIMIT 20 OFFSET 0","errors":["PG::Error: ERROR: column katello_errata.name does not exist\nLINE 1: ....\"id\" FROM \"katello_content_views\"))))) ORDER BY \"katello_e...\n ^\n: SELECT \"katello_errata\".* FROM \"katello_errata\" WHERE \"katello_errata\".\"id\" IN (SELECT \"katello_repository_errata\".\"erratum_id\" FROM \"katello_repository_errata\" WHERE \"katello_repository_errata\".\"repository_id\" IN (SELECT \"katello_repositories\".\"id\" FROM \"katello_repositories\" WHERE (katello_repositories.id in (SELECT \"katello_repositories\".\"id\" FROM \"katello_repositories\" WHERE \"katello_repositories\".\"product_id\" IN (SELECT \"katello_products\".\"id\" FROM \"katello_products\")) or katello_repositories.id in (SELECT \"katello_repositories\".\"id\" FROM \"katello_repositories\" INNER JOIN \"katello_content_view_repositories\" ON \"katello_content_view_repositories\".\"repository_id\" = \"katello_repositories\".\"id\" WHERE \"katello_content_view_repositories\".\"content_view_id\" IN (SELECT \"katello_content_views\".\"id\" FROM \"katello_content_views\")) or katello_repositories.id in (SELECT \"katello_repositories\".\"id\" FROM \"katello_repositories\" INNER JOIN \"katello_content_view_versions\" ON \"katello_content_view_versions\".\"id\" = \"katello_repositories\".\"content_view_version_id\" WHERE \"katello_content_view_versions\".\"content_view_id\" IN (SELECT \"katello_content_views\".\"id\" FROM \"katello_content_views\"))))) ORDER BY \"katello_errata\".\"name\" ASC, katello_errata.id DESC LIMIT 20 OFFSET 0"]}
Associated revisions
History
#1
Updated by Partha Aji over 4 years ago
- Bugzilla link set to 1507519
#2
Updated by The Foreman Bot over 4 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/Katello/katello/pull/7046 added
#3
Updated by Justin Sherrill over 4 years ago
- Legacy Backlogs Release (now unused) set to 284
#4
Updated by Justin Sherrill over 4 years ago
- Legacy Backlogs Release (now unused) changed from 284 to 250
#5
Updated by Partha Aji over 4 years ago
- % Done changed from 0 to 100
- Status changed from Ready For Testing to Closed
Applied in changeset katello|2e39affb47849ebd42f6974892e7618ed6c5dbd5.
Fixes #21525 - Handles API invalid column sort
This commit contains code that appropriately errors out
if an invalid/non existent column is provided for sorting.