Bug #21065
closedCan't create configuration as a user with just "Manager" and "Virt-who Manager" roles
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:
- Create a non-admin user with roles "Manager" and "Virt-who Manager"
- Add that user to some organizations and locations
- Login as that user and switch to any context
- Try to create a virt-who configuration
Updated by Marek Hulán over 7 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
Updated by Marek Hulán over 7 years ago
- Related to Bug #16884: Create permissions do not check filter limits added
Updated by The Foreman Bot over 7 years ago
- Pull request https://github.com/theforeman/foreman_virt_who_configure/pull/68 added
Updated by Marek Hulán over 7 years ago
- Status changed from New to Ready For Testing
- Translation missing: en.field_release set to 308
Updated by Marek Hulán over 7 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset foreman_virt_who_configure|7c4de9a684cbe9fe82ed6d7d2c01d4ceedc81973.