Bug 1311399

Summary: Web-UI:rbac:Clicking on Users or Groups with restricted role user throws "undefined method `where' for #<Array:0x000000057a2510> [ops/tree_select]" error.
Product: Red Hat CloudForms Management Engine Reporter: Ramesh A <rananda>
Component: UI - OPSAssignee: Harpreet Kataria <hkataria>
Status: CLOSED ERRATA QA Contact: Ramesh A <rananda>
Severity: medium Docs Contact:
Priority: high    
Version: 5.5.0CC: hkataria, jhardy, jprause, mfeifer, mpovolny, obarenbo
Target Milestone: GAKeywords: ZStream
Target Release: 5.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: rbac:ui:error
Fixed In Version: 5.6.0.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1311995 (view as bug list) Environment:
Last Closed: 2016-06-29 15:39:29 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: 1311995    
Attachments:
Description Flags
error none

Description Ramesh A 2016-02-24 07:43:26 UTC
Created attachment 1130074 [details]
error

Description of problem:
Clicking on Users or Groups with restricted role user throws "undefined method `where' for #<Array:0x000000057a2510> [ops/tree_select]" error.

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

How reproducible:
100%

Steps to Reproduce:
1. Navigate to Configure ==> Configuration ==> Access Control
2. Create a new role with "VM & Template Access Restriction" as "Only User or Group Owned" or "Only User Owned".  Make sure all the module access is given in "Product Features (Editing)" i.e., Everything is checked
3. Create a new group with the above role
4. Create a new user with the above group
5. Login with the newly created user and navigate to Configure ==> Configuration ==> Access Control
6. Click on Users or Groups

Actual results:
Throws "undefined method `where' for #<Array:0x000000057a2510> [ops/tree_select]" error.  Refer the screenshot and production.log for further information

Expected results:
Should not display any error message

Additional info:
production.log:
===============
[----] I, [2016-02-24T02:28:15.472723 #2975:ce7994]  INFO -- : Completed 200 OK in 80ms (Views: 0.3ms | ActiveRecord: 6.2ms)
[----] I, [2016-02-24T02:28:17.763792 #2975:ce7994]  INFO -- : Started POST "/ops/tree_select/?id=xx-u" for 127.0.0.1 at 2016-02-24 02:28:17 -0500
[----] I, [2016-02-24T02:28:17.766321 #2975:ce7994]  INFO -- : Processing by OpsController#tree_select as JS
[----] I, [2016-02-24T02:28:17.766491 #2975:ce7994]  INFO -- :   Parameters: {"id"=>"xx-u"}
[----] F, [2016-02-24T02:28:17.858658 #2975:ce7994] FATAL -- : Error caught: [NoMethodError] undefined method `where' for #<Array:0x00000002bd8470>
/var/www/miq/vmdb/app/models/rbac.rb:266:in `find_targets_with_user_group_rbac'
/var/www/miq/vmdb/app/models/rbac.rb:290:in `find_targets_with_rbac'
/var/www/miq/vmdb/app/models/rbac.rb:449:in `search'
/var/www/miq/vmdb/app/models/miq_report/search.rb:113:in `paged_view_search'
/var/www/miq/vmdb/app/controllers/application_controller.rb:1750:in `get_view'
/var/www/miq/vmdb/app/controllers/ops_controller/ops_rbac.rb:776:in `rbac_build_list'
/var/www/miq/vmdb/app/controllers/ops_controller/ops_rbac.rb:750:in `rbac_list'
/var/www/miq/vmdb/app/controllers/ops_controller/ops_rbac.rb:334:in `rbac_users_list'
/var/www/miq/vmdb/app/controllers/ops_controller/ops_rbac.rb:865:in `rbac_get_info'
/var/www/miq/vmdb/app/controllers/ops_controller.rb:432:in `get_node_info'
/var/www/miq/vmdb/app/controllers/ops_controller.rb:205:in `tree_select'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/abstract_controller/base.rb:198:in `process_action'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_controller/metal/rendering.rb:10:in `process_action'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:117:in `call'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:117:in `call'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:505:in `call'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:505:in `call'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/abstract_controller/callbacks.rb:19:in `process_action'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_controller/metal/rescue.rb:29:in `process_action'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/notifications.rb:164:in `block in instrument'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/notifications.rb:164:in `instrument'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
/opt/rh/cfme-gemset/gems/activerecord-4.2.5.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/abstract_controller/base.rb:137:in `process'
/opt/rh/cfme-gemset/gems/actionview-4.2.5.1/lib/action_view/rendering.rb:30:in `process'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_controller/metal.rb:196:in `dispatch'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_controller/metal.rb:237:in `block in action'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/routing/route_set.rb:74:in `call'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/routing/route_set.rb:43:in `serve'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/journey/router.rb:43:in `block in serve'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/journey/router.rb:30:in `each'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/journey/router.rb:30:in `serve'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/routing/route_set.rb:815:in `call'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/etag.rb:24:in `call'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/conditionalget.rb:38:in `call'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/flash.rb:260:in `call'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:225:in `context'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in `call'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/cookies.rb:560:in `call'
/opt/rh/cfme-gemset/gems/activerecord-4.2.5.1/lib/active_record/query_cache.rb:36:in `call'
/opt/rh/cfme-gemset/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
/opt/rh/cfme-gemset/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:38:in `call_app'
/opt/rh/cfme-gemset/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:22:in `call'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'
/opt/rh/cfme-gemset/gems/activesupport-4.2.5.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/lock.rb:17:in `call'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/static.rb:116:in `call'
/opt/rh/cfme-gemset/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/static.rb:116:in `call'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'
/opt/rh/cfme-gemset/gems/railties-4.2.5.1/lib/rails/engine.rb:518:in `call'
/opt/rh/cfme-gemset/gems/railties-4.2.5.1/lib/rails/application.rb:165:in `call'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/thin-1.6.3/lib/thin/connection.rb:86:in `block in pre_process'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/thin-1.6.3/lib/thin/connection.rb:84:in `catch'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/thin-1.6.3/lib/thin/connection.rb:84:in `pre_process'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/thin-1.6.3/lib/thin/connection.rb:53:in `process'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/thin-1.6.3/lib/thin/connection.rb:39:in `receive_data'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run_machine'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/thin-1.6.3/lib/thin/backends/base.rb:73:in `start'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/thin-1.6.3/lib/thin/server.rb:162:in `start'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/handler/thin.rb:19:in `run'
/opt/rh/cfme-gemset/gems/rack-1.6.4/lib/rack/server.rb:286:in `start'
/opt/rh/cfme-gemset/gems/railties-4.2.5.1/lib/rails/commands/server.rb:80:in `start'
/opt/rh/cfme-gemset/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:80:in `block in server'
/opt/rh/cfme-gemset/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
/opt/rh/cfme-gemset/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:75:in `server'
/opt/rh/cfme-gemset/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
/opt/rh/cfme-gemset/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in `<top (required)>'
/var/www/miq/vmdb/bin/rails:4:in `require'
/var/www/miq/vmdb/bin/rails:4:in `<main>'
[----] I, [2016-02-24T02:28:17.861198 #2975:ce7994]  INFO -- :   Rendered layouts/_exception_contents.html.haml (0.3ms)
[----] I, [2016-02-24T02:28:17.862037 #2975:ce7994]  INFO -- : Completed 200 OK in 95ms (Views: 1.9ms | ActiveRecord: 4.8ms)
[----] I, [2016-02-24T02:28:20.999019 #2975:ce7994]  INFO -- : Started POST "/dashboard/window_sizes?width=1680&height=910" for 127.0.0.1 at 2016-02-24 02:28:20 -0500
[----] I, [2016-02-24T02:28:21.001389 #2975:ce7994]  INFO -- : Processing by DashboardController#window_sizes as JS
[----] I, [2016-02-24T02:28:21.001561 #2975:ce7994]  INFO -- :   Parameters: {"width"=>"1680", "height"=>"910"}
[----] I, [2016-02-24T02:28:21.010293 #2975:ce7994]  INFO -- :   Rendered text template (0.0ms)
[----] I, [2016-02-24T02:28:21.010727 #2975:ce7994]  INFO -- : Completed 200 OK in 9ms (Views: 0.8ms | ActiveRecord: 0.0ms)
[----] I, [2016-02-24T02:28:36.581322 #2975:ce7994]  INFO -- : Started POST "/dashboard/window_sizes?width=1366&height=601" for 127.0.0.1 at 2016-02-24 02:28:36 -0500
[----] I, [2016-02-24T02:28:36.583596 #2975:ce7994]  INFO -- : Processing by DashboardController#window_sizes as JS
[----] I, [2016-02-24T02:28:36.583727 #2975:ce7994]  INFO -- :   Parameters: {"width"=>"1366", "height"=>"601"}
[----] I, [2016-02-24T02:28:36.592254 #2975:ce7994]  INFO -- :   Rendered text template (0.0ms)
[----] I, [2016-02-24T02:28:36.592675 #2975:ce7994]  INFO -- : Completed 200 OK in 9ms (Views: 0.7ms | ActiveRecord: 0.0ms)

Comment 2 Harpreet Kataria 2016-02-25 16:55:03 UTC
This issue has already been fixed on upstream in commit 978efcbb50a5a80a303146ba19aa669ed42d607c

https://github.com/ManageIQ/manageiq/pull/6437

Only needs to be cherry-picked on to 5.5.z

Comment 3 CFME Bot 2016-02-26 20:12:16 UTC
New commit detected on cfme/5.5.z:
https://code.engineering.redhat.com/gerrit/gitweb?p=cfme.git;a=commitdiff;h=f91c73d4b6720192c64dd6c16efae9c123b46bd4

commit f91c73d4b6720192c64dd6c16efae9c123b46bd4
Merge: e2c7013 65c45b4
Author:     Dan Clarizio <dclarizi>
AuthorDate: Fri Feb 26 14:52:15 2016 -0500
Commit:     Dan Clarizio <dclarizi>
CommitDate: Fri Feb 26 14:52:15 2016 -0500

    Merge branch '55z_bz_1311995' into '5.5.z'
    
    Fix list of group and user with self_service user
    
    Self service user means that user's role has option
    "VM & Template Access Restriction" set up to "Only User Owned" or
    "Only User or Group Owned"
    (cherry picked from commit 978efcb)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1311995
    https://bugzilla.redhat.com/show_bug.cgi?id=1311399
    
    @dclarizi please review, this is cherry pick of commit 978efcbb50a5a80a303146ba19aa669ed42d607c from https://github.com/ManageIQ/manageiq/pull/6437
    
    See merge request !816

 app/models/rbac.rb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comment 4 Ramesh A 2016-04-22 14:26:52 UTC
Good to go.  Verified and working fine in 5.6.0.4-beta2.3.20160421172650_719e256

Comment 6 errata-xmlrpc 2016-06-29 15:39:29 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/RHBA-2016:1348