Bug #17244

Error accessing dashboard when user has filtered access to hosts

Added by Tomer Brisker 6 months ago. Updated 5 months ago.

Status:Closed
Priority:Normal
Assigned To:Tomer Brisker
Category:Dashboard
Target version:Foreman - Team Daniel - iteration 6
Difficulty: Pull request:https://github.com/Katello/katello/pull/6443
Bugzilla link:1232877
Story points-
Velocity based estimate-
Release3.2.1Release relationshipAuto

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

Related to Foreman - Bug #16704: Searching fails on dashboard Closed 09/27/2016
Related to Foreman - Bug #16044: Errors in individual dashboard widgets fail entire page Closed 08/10/2016

Associated revisions

Revision 0eddf0db
Added by Tomer Brisker 5 months ago

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

History

#1 Updated by Tomer Brisker 6 months ago

  • Related to Bug #16704: Searching fails on dashboard added

#2 Updated by The Foreman Bot 6 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/6443 added

#3 Updated by Justin Sherrill 5 months ago

  • Release set to 3.2.1

#4 Updated by Daniel Lobato Garcia 5 months ago

  • Target version set to Team Daniel - iteration 6

#5 Updated by Anonymous 5 months ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#6 Updated by Tomer Brisker 4 months ago

  • Related to Bug #16044: Errors in individual dashboard widgets fail entire page added

Also available in: Atom PDF