Project

General

Profile

Actions

Bug #21065

closed

Can't create configuration as a user with just "Manager" and "Virt-who Manager" roles

Added by Tomáš Strachota over 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Creating a configuration from Any context as a user with just "Manager" and "Virt-who Manager" roles fails with "PG::NotNullViolation: ERROR: null value in column "user_id" violates not-null constraint":

2017-09-21T22:28:42 17402e8b [app] [I] Completed 500 Internal Server Error in 42944ms (ActiveRecord: 142.3ms)
2017-09-21T22:28:42 17402e8b [app] [F]
 | ActiveRecord::StatementInvalid (PG::NotNullViolation: ERROR:  null value in column "user_id" violates not-null constraint
 | DETAIL:  Failing row contains (26, EV8pHjVRg8bnpUSm, null, 2017-09-21 20:28:38.444197, 2017-09-21 20:28:38.444197).                                 
 | : INSERT INTO "foreman_virt_who_configure_service_users" ("encrypted_password", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"):    
 |   /root/foreman/foreman_virt_who_configure/app/models/foreman_virt_who_configure/config.rb:134:in `create_service_user'
 |   /root/foreman/foreman_virt_who_configure/app/controllers/foreman_virt_who_configure/configs_controller.rb:38:in `create'
 |   app/controllers/concerns/application_shared.rb:15:in `set_timezone'
 |   app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 |   app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 |   /root/foreman/katello/lib/katello/params_parser_wrapper.rb:12:in `call'
 |   lib/middleware/catch_json_parse_errors.rb:8:in `call'
 |   lib/middleware/session_safe_logging.rb:17:in `call'
 |   lib/middleware/tagged_logging.rb:18:in `call'

Closer inspection showed that there's problem with saving the service user (class User). The record had following errors:

  {:location_ids=>["Invalid locations selection, you must select at least one of yours and have 'assign_locations' permission."],
   :role_ids=>["you can't assign some of roles you selected"],
   :auth_source=>["is not permitted"]}

The user had multiple organizations and locations assigned. Selecting a location in the context menu helped with saving the user and the configuration, but the ServiceUser record was still not saved, which resulted in following error on the configuration detail page:

2017-09-21T22:34:51 0f8a0d02 [app] [I] Completed 500 Internal Server Error in 58ms (ActiveRecord: 11.1ms)
2017-09-21T22:34:51 0f8a0d02 [app] [F]
 | ActionView::Template::Error (undefined method `encrypted_password' for nil:NilClass)
 |     50:     </div>
 |     51:     <div class="row">
 |     52:       <div class="col-md-8">
 |     53:         <pre class="terminal" id="config_script"><%= @config.virt_who_config_script %></pre>
 |     54:       </div>
 |     55:       <div class="col-md-8">
 |     56:         <div class="terminal-buttons">
 |   /root/foreman/foreman_virt_who_configure/app/models/foreman_virt_who_configure/output_generator.rb:210:in `service_user_password'
 |   /root/foreman/foreman_virt_who_configure/app/models/foreman_virt_who_configure/output_generator.rb:88:in `virt_who_output'
 |   /root/foreman/foreman_virt_who_configure/app/models/foreman_virt_who_configure/config.rb:181:in `virt_who_config_script'
 |   /root/foreman/foreman_virt_who_configure/app/views/foreman_virt_who_configure/configs/show.html.erb:53:in `_dcb145bbdb958d98ab26e86bd2dff887'
 |   app/controllers/concerns/application_shared.rb:15:in `set_timezone'
 |   app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 |   app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 |   /root/foreman/katello/lib/katello/params_parser_wrapper.rb:12:in `call'
 |   lib/middleware/catch_json_parse_errors.rb:8:in `call'
 |   lib/middleware/session_safe_logging.rb:17:in `call'
 |   lib/middleware/tagged_logging.rb:18:in `call'

Reproducer steps:
  1. Create a non-admin user with roles "Manager" and "Virt-who Manager"
  2. Add that user to some organizations and locations
  3. Login as that user and switch to any context
  4. Try to create a virt-who configuration

Related issues 1 (0 open1 closed)

Related to Foreman - Bug #16884: Create permissions do not check filter limitsClosedMarek Hulán10/12/2016Actions
Actions #1

Updated by Marek Hulán over 6 years ago

  • Assignee set to Marek Hulán

Turn out to be Foreman 1.16 problem only caused by #16884, the fix will bump the dependency and bump the version

Actions #2

Updated by Marek Hulán over 6 years ago

  • Related to Bug #16884: Create permissions do not check filter limits added
Actions #3

Updated by The Foreman Bot over 6 years ago

  • Pull request https://github.com/theforeman/foreman_virt_who_configure/pull/68 added
Actions #4

Updated by Marek Hulán over 6 years ago

  • Status changed from New to Ready For Testing
  • translation missing: en.field_release set to 308
Actions #5

Updated by Marek Hulán over 6 years ago

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

Also available in: Atom PDF