Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1296782

Summary: Executing "hammer role filters" command throws SQL errors
Product: Red Hat Satellite Reporter: Nagoor Shaik <nshaik>
Component: SearchAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Katello QA List <katello-qa-list>
Severity: high Docs Contact:
Priority: high    
Version: 6.1.4CC: bbuckingham, bkearney, kabbott, pondrejk, rankumar, sthirugn
Target Milestone: UnspecifiedKeywords: Patch, Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
URL: http://projects.theforeman.org/issues/13645
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:54:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1479962    

Description Nagoor Shaik 2016-01-08 02:40:40 UTC
Description of problem:
Executing "hammer role filters" command throws SQL errors

Version-Release number of selected component (if applicable):
foreman-1.7.2.46-1.el7sat.noarch
foreman-compute-1.7.2.46-1.el7sat.noarch
foreman-debug-1.7.2.46-1.el7sat.noarch
foreman-gce-1.7.2.46-1.el7sat.noarch
foreman-libvirt-1.7.2.46-1.el7sat.noarch
foreman-ovirt-1.7.2.46-1.el7sat.noarch
foreman-postgresql-1.7.2.46-1.el7sat.noarch
foreman-proxy-1.7.2.6-1.el7sat.noarch
foreman-selinux-1.7.2.16-1.el7sat.noarch
foreman-vmware-1.7.2.46-1.el7sat.noarch
ruby193-rubygem-foreman_bootdisk-4.0.2.13-1.el7sat.noarch
ruby193-rubygem-foreman_discovery-2.0.0.19-1.el7sat.noarch
ruby193-rubygem-foreman_docker-1.2.0.24-1.el7sat.noarch
ruby193-rubygem-foreman_gutterball-0.0.1.9-1.el7sat.noarch
ruby193-rubygem-foreman_hooks-0.3.7-2.el7sat.noarch
ruby193-rubygem-foreman-redhat_access-0.2.3-1.el7sat.noarch
ruby193-rubygem-foreman-tasks-0.6.15.7-1.el7sat.noarch
rubygem-hammer_cli-0.1.4.13-1.el7sat.noarch
rubygem-hammer_cli_foreman-0.1.4.14-1.el7sat.noarch
rubygem-hammer_cli_foreman_bootdisk-0.1.2.7-1.el7sat.noarch
rubygem-hammer_cli_foreman_discovery-0.0.1.10-1.el7sat.noarch
rubygem-hammer_cli_foreman_docker-0.0.3.9-1.el7sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3.5-1.el7sat.noarch
rubygem-hammer_cli_gutterball-0.0.1.3-1.el7sat.noarch
rubygem-hammer_cli_import-0.10.20-1.el7sat.noarch
rubygem-hammer_cli_katello-0.0.7.18-1.el7sat.noarch


How reproducible:
100 %

Steps to Reproduce:
1. Execute hammer role filters
     
# hammer role filters
PGError: ERROR:  invalid input syntax for integer: ""
LINE 1: ..."id" = "filters"."role_id" WHERE (("roles"."id" = '')) ORDER...
                                                             ^
: SELECT  "filters"."id" AS t0_r0, "filters"."search" AS t0_r1, "filters"."role_id" AS t0_r2, "filters"."created_at" AS t0_r3, "filters"."updated_at" AS t0_r4, "filters"."taxonomy_search" AS t0_r5, "roles"."id" AS t1_r0, "roles"."name" AS t1_r1, "roles"."builtin" AS t1_r2, "roles"."permissions" AS t1_r3 FROM "filters" LEFT OUTER JOIN "roles" ON "roles"."id" = "filters"."role_id" WHERE (("roles"."id" = '')) ORDER BY role_id, filters.id LIMIT 20 OFFSET 0

Actual results:
Throws SQL errors when executing the command

Expected results:
Ideally it should display a warning stating that ID of the role is missing

Additional info:
"hammer role filters" command is expecting an ID to be passed in with the command, if it finds NULL then it throws the above SQL error. 

  # hammer role list
---|-----------------------
ID | NAME                  
---|-----------------------
1  | Discovery Reader      
2  | Discovery Manager     
3  | Tasks Manager         
4  | Tasks Reader          
5  | Red Hat Access Logs   
6  | Access Insights Viewer
7  | Access Insights Admin 
8  | Boot disk access      
9  | Manager               
10 | Edit partition tables 
11 | View hosts            
12 | Edit hosts            
13 | Viewer                
14 | Site manager          
15 | Default user          
16 | Anonymous             
17 | Admin                 
---|-----------------------

  # hammer role filter --id 1 ---> This command works fine
---|---------------|--------|------------|------------------|----------------------
ID | RESOURCE TYPE | SEARCH | UNLIMITED? | ROLE             | PERMISSIONS          
---|---------------|--------|------------|------------------|----------------------
1  | Location      | none   | yes        | Discovery Reader | view_locations       
2  | Organization  | none   | yes        | Discovery Reader | view_organizations   
3  | Host          | none   | yes        | Discovery Reader | view_discovered_hosts
4  | DiscoveryRule | none   | yes        | Discovery Reader | view_discovery_rules 
---|---------------|--------|------------|------------------|----------------------

Comment 3 Bryan Kearney 2016-01-26 13:55:35 UTC
Moving this out of 6.1.7 due to capacity issues. Will keep it on the 6.1.z and 6.2 trackers to ensure that it is evaluated for both.

Comment 7 Brad Buckingham 2016-03-16 15:26:07 UTC
Created redmine issue http://projects.theforeman.org/issues/14235 from this bug

Comment 8 Bryan Kearney 2016-03-16 16:13:11 UTC
Upstream bug component is Provisioning

Comment 9 Ranjan Kumar 2016-04-12 07:40:11 UTC
patch added http://projects.theforeman.org/issues/13064

Comment 14 Bryan Kearney 2016-08-10 19:12:41 UTC
Upstream bug component is Search

Comment 15 Bryan Kearney 2016-08-10 20:13:40 UTC
Upstream bug component is Provisioning

Comment 16 Bryan Kearney 2016-08-10 22:13:19 UTC
Upstream bug component is Search

Comment 17 Bryan Kearney 2016-08-23 11:43:43 UTC
*** Bug 1368408 has been marked as a duplicate of this bug. ***

Comment 19 Karl Abbott 2017-04-12 19:21:47 UTC
any chance we can get a target 6.2.z for this one?

Karl

Comment 23 Stanislav Tkachenko 2017-06-06 06:50:54 UTC
Verified on Sat 6.3 Snap 1.0 with automation test:

2017-06-06 09:48:45 - robottelo.ssh - INFO - >>> LANG=en_US.UTF-8  hammer -v -u admin -p changeme --output=json role filters 
2017-06-06 09:48:47 - robottelo.ssh - INFO - <<< stderr
[ERROR 2017-06-06 02:48:47 Exception] Error: At least one of options --name, --id is required

See: 'hammer role filters --help'

Comment 26 Satellite Program 2018-02-21 16:54:17 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