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 1921150 - Tasks view fails for non-admin with PG::SyntaxError: ERROR: syntax error at or near "'1,6,4,3,5'"
Summary: Tasks view fails for non-admin with PG::SyntaxError: ERROR: syntax error at ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Tasks Plugin
Version: 6.9.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: 6.9.0
Assignee: Adam Ruzicka
QA Contact: Peter Ondrejka
URL:
Whiteboard:
Depends On:
Blocks: 1741943
TreeView+ depends on / blocked
 
Reported: 2021-01-27 15:30 UTC by Peter Ondrejka
Modified: 2021-04-21 13:11 UTC (History)
3 users (show)

Fixed In Version: tfm-rubygem-foreman-tasks-3.0.5
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-04-21 13:10:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
prodlog (25.81 KB, text/plain)
2021-01-27 15:31 UTC, Peter Ondrejka
no flags Details
prodlog2 (19.90 KB, text/plain)
2021-01-27 15:32 UTC, Peter Ondrejka
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 31773 0 Normal Closed Tasks view fails for non-admin with PG::SyntaxError: ERROR: syntax error at or near "\'1,6,4,3,5\'" 2021-02-19 16:14:50 UTC
Red Hat Product Errata RHSA-2021:1313 0 None None None 2021-04-21 13:11:04 UTC

Description Peter Ondrejka 2021-01-27 15:30:52 UTC
Description of problem:
Viewing the tasks page as non admin user with cloned manager role that has organizations assigned fails in ui with:

Could not receive data: Request failed with status code 500

prodlog (attached) shows:

[I|app|f5671e24] Backtrace for 'Action failed' error (ActionView::Template::      Error): PG::SyntaxError: ERROR:  syntax error at or near "'1,6,4,3,5'"
   f5671e24 | LINE 9: ...foreman_tasks_locks_taxonomy5f5e24.resource_id IN '1,6,4,3,5...
   f5671e24 |                                                              ^

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

Satellite 6.8 snap 10

How reproducible:
always

Steps to Reproduce:
1. Have a satellite with mutliple orgs
2. Clone a manager role, assign it to all or some orgs
3. Create a user, assign the role to it, assign it to one or more of the role's orgs
4. Log in as the user or impersonate, navigate to Monitor > Tasks

Actual results:
No tasks listed, above errors shown

Expected results:
Tasks viewed as exoected

Additional info:
Seems to be related to org assignment in cloned role, using the default manager role or using a cloned role with no org assigned doesn't produce this issue

Comment 1 Peter Ondrejka 2021-01-27 15:31:57 UTC
Created attachment 1751293 [details]
prodlog

Comment 2 Peter Ondrejka 2021-01-27 15:32:36 UTC
Created attachment 1751294 [details]
prodlog2

Comment 3 Adam Ruzicka 2021-02-01 09:40:01 UTC
Alternative steps to reproduce:

1) run foreman-rake console
2) Enter ForemanTasks::Task.search_for("organization_id ^ (1)").first

Note:
Searching by taxonomies on tasks still uses a custom external method, which doesn't handle queries with IN well.

Comment 4 Peter Ondrejka 2021-02-01 10:54:47 UTC
Hello, on Satellite 6.8.3:

~]# foreman-rake console
ForemanTasks::Task.search_for("organization_id ^ (1)").first
Loading production environment (Rails 6.0.3.1)
irb(main):001:0> ForemanTasks::Task.search_for("organization_id ^ (1)").first
Traceback (most recent call last):
        2: from lib/tasks/console.rake:5:in `block in <top (required)>'
        1: from (irb):1
ActiveRecord::StatementInvalid (PG::SyntaxError: ERROR:  syntax error at or near "'1'")
LINE 3: ...foreman_tasks_locks_taxonomyb72f2d.resource_id IN '1' OR for...
                                                             ^

Comment 5 Bryan Kearney 2021-02-10 12:03:05 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/31773 has been resolved.

Comment 6 Adam Ruzicka 2021-02-11 08:49:43 UTC
Requesting 6.9.0+ since this blocks https://bugzilla.redhat.com/show_bug.cgi?id=1741943

Comment 9 Peter Ondrejka 2021-03-01 14:44:59 UTC
Verified on Satellite 6.9 snap 15

Comment 10 Peter Ondrejka 2021-03-01 15:16:32 UTC
Sorry, taking back comment#9, the verification steps from comment#3 work well, though when using original steps (cloned role with multiple orgs and user with some of those orgs) the issue persists with the following in the production log:

PG::InvalidTextRepresentation: ERROR:  invalid input syntax for type integer: "1,3,5,7,6,4"
 ab598f13 | LINE 7: ...oreman_tasks_locks_taxonomyc9ce1d.resource_id IN ('1,3,5,7,6...

Comment 11 Peter Ondrejka 2021-03-08 12:26:50 UTC
Hi Zach, I still see tfm-rubygem-foreman-tasks-3.0.4 on snap 16, did we miss a cherry-pick?

Comment 12 Peter Ondrejka 2021-03-12 09:37:43 UTC
Verified on Satellite 6.9 snap 17

Comment 15 errata-xmlrpc 2021-04-21 13:10: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 (Moderate: Satellite 6.9 Release), 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-2021:1313


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