Bug 1507519 - PG::Error: ERROR: column katello_errata.name does not exist - on ordering the errata list via API
Summary: PG::Error: ERROR: column katello_errata.name does not exist - on ordering th...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Errata Management
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Partha Aji
QA Contact: Roman Plevka
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-10-30 13:33 UTC by Roman Plevka
Modified: 2019-09-26 16:11 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 16:46:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 21525 0 Normal Closed ISE on Errata API list call when using invalid sort by name 2020-08-03 12:51:53 UTC

Description Roman Plevka 2017-10-30 13:33:24 UTC
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

Comment 2 Ivan Necas 2017-10-31 13:06:55 UTC
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.

Comment 3 Brad Buckingham 2017-10-31 14:51:13 UTC
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?

Comment 4 Roman Plevka 2017-10-31 15:09:28 UTC
https://<sat6fqdn>/apidoc/v2/errata/index.html
scroll down to the "order" option.
this also happens on "cve" field

Comment 5 Partha Aji 2017-10-31 22:35:08 UTC
Connecting redmine issue http://projects.theforeman.org/issues/21525 from this bug

Comment 6 Satellite Program 2017-11-02 04:15:04 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/21525 has been resolved.

Comment 7 Roman Plevka 2017-11-03 17:08:04 UTC
Hi.
How can i get an actual list of valid fields for searching?

Comment 11 jcallaha 2017-11-03 19:12:58 UTC
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...

Comment 12 Bryan Kearney 2018-02-21 16:42:16 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-2018:0336

Comment 13 Bryan Kearney 2018-02-21 16:46:18 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-2018:0336


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