Bug #17244
Error accessing dashboard when user has filtered access to hosts
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1232877
Description of problem:
When a user with filtered access to hosts attempts to access the dashboard he receives an Oops messages. The user has also been give view access to the dashboard.
Full call trace:
ActiveRecord::StatementInvalid
PGError: ERROR: missing FROM-clause entry for table "compute_resources" LINE 1: ...(2) AND "hosts"."type" IN ('Host::Managed') AND (("compute_r... ^ : SELECT COUNT FROM (SELECT "reports"."id" AS count_column FROM "reports" LEFT OUTER JOIN "hosts" ON "hosts"."id" = "reports"."host_id" AND "hosts"."type" IN ('Host::Managed') WHERE "reports"."host_id" IN (SELECT "hosts"."id" FROM "hosts" WHERE "hosts"."organization_id" IN (1) AND "hosts"."location_id" IN (2) AND "hosts"."type" IN ('Host::Managed') AND (("compute_resources"."name" = 'RHEV')) ORDER BY "hosts"."name" ASC NULLS FIRST ) AND (status <> 0) AND (("reports"."reported_at" >= '2015-06-09')) LIMIT 6) subquery_for_count
app/views/dashboard/_reports_widget.html.erb:3:in `_app_views_dashboard__reports_widget_html_erb___268700215681041418_127681020'
app/views/dashboard/index.html.erb:8:in `block in app_views_dashboard_index_html_erb_604474822609035711_127215680'
app/views/dashboard/index.html.erb:7:in `map'
app/views/dashboard/index.html.erb:7:in `_app_views_dashboard_index_html_erb__604474822609035711_127215680'
app/controllers/dashboard_controller.rb:6:in `index'
app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
lib/middleware/catch_json_parse_errors.rb:9:in `call'
Related issues
Associated revisions
History
#1
Updated by Tomer Brisker over 5 years ago
- Related to Bug #16704: Searching fails on dashboard added
#2
Updated by The Foreman Bot over 5 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/Katello/katello/pull/6443 added
#3
Updated by Justin Sherrill over 5 years ago
- Legacy Backlogs Release (now unused) set to 197
#4
Updated by Daniel Lobato Garcia over 5 years ago
- Target version set to 1.4.3
#5
Updated by Anonymous over 5 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset katello|0eddf0db230e417a049aea512c43ab6f592a59ab.
#6
Updated by Tomer Brisker over 5 years ago
- Related to Bug #16044: Errors in individual dashboard widgets fail entire page added
Fixes #17244 - Errata widget does not break on filtered hosts
Due to an issue with how rails handles inner queries with complex
conditions, we need to manually generate the SQL for the errata widget
to correctly select the correct host ids in case there is a filter in
place on one of the related tables (for example, compute_resource).
This fix is similar to the fix for
http://projects.theforeman.org/issues/16704