Description of problem: I believe that fix for https://bugzilla.redhat.com/show_bug.cgi?id=1479450 has either revealed another problem or introduced a regression. Backend does not recognize some of the columns for ordering, e.g.: $ curl -sku admin:changeme "https://qe-sat63-rhel7.satqe.lab.eng.rdu2.redhat.com/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"]} Version-Release number of selected component (if applicable): since 6.3.0-19 How reproducible: Steps to Reproduce: 1. you might need to have som repos providing some errata synced. 2. curl -sku admin:changeme "https://satelite.com/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 Additional info: apidoc explicitly uses `name DESC` as an example, so i assume, this one should work at least
It doesn't seem there was such an field for ordering in the past. The right sort attribute to sort by should be `title`. The proper fix should be validating what field we want to accept and printing more useful message on invalid data.
Ivan, thanks for the feedback and you are correct, 'name' is not an attribute of an erratum. Roman, which apidoc do you see name referenced in? I looked at the one on my sat6 install, but did not see it. Also, does the api sorting by 'title' work properly?
https://<sat6fqdn>/apidoc/v2/errata/index.html scroll down to the "order" option. this also happens on "cve" field
Connecting redmine issue http://projects.theforeman.org/issues/21525 from this bug
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/21525 has been resolved.
Hi. How can i get an actual list of valid fields for searching?
Verified in Satellite 6.3 Beta Snap 23. Before upgrading, the problem still persisted. $ curl -sku admin:changeme "https://rhsm-qe-1.rhq.lab.eng.bos.redhat.com/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"]} After the upgrade, we are no longer presented with the pg error, but are now correctly notified that the field is invalid. $ curl -sku admin:changeme "https://rhsm-qe-1.rhq.lab.eng.bos.redhat.com/katello/api/v2/errata?order=name%20ASC" {"total":null,"subtotal":null,"page":null,"per_page":null,"error":"the field (name) in the order statement is not valid field for search","search":null,"sort":{"by":"name","order":"ASC"},"results":[]} $ curl -sku admin:changeme "https://rhsm-qe-1.rhq.lab.eng.bos.redhat.com/katello/api/v2/errata?order=cve" {"total":null,"subtotal":null,"page":null,"per_page":null,"error":"the field (cve) in the order statement is not valid field for search","search":null,"sort":{"by":"cve","order":null},"results":[]} $ curl -sku admin:changeme "https://rhsm-qe-1.rhq.lab.eng.bos.redhat.com/katello/api/v2/errata?order=test" {"total":null,"subtotal":null,"page":null,"per_page":null,"error":"the field (test) in the order statement is not valid field for search","search":null,"sort":{"by":"test","order":null},"results":[]} ordering by an accepted field still works. $ curl -sku admin:changeme "https://rhsm-qe-1.rhq.lab.eng.bos.redhat.com/katello/api/v2/errata?order=id%20DESC" {"total":6748,"subtotal":6748,"page":1,"per_page":20,"error":null,"search":null,"sort":{"by":"id","order":"desc"},"results":[{"id":"f9096...
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-2018:0336