Bug #19417

keep_params throws error if params don't contain top level hash

Added by Tomer Brisker 4 months ago. Updated about 1 month ago.

Status:Closed
Priority:Normal
Assigned To:Tomer Brisker
Category:Rails
Target version:-
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman/pull/4491
Story points-
Velocity based estimate-
Release1.15.3Release relationshipAuto

Description

This can be reproduced in discovery by trying to provision a host and selecting an architecture

 | NoMethodError (undefined method `has_key?' for nil:NilClass):
 |   app/controllers/concerns/foreman/controller/parameters/keep_param.rb:11:in `block in keep_param'
 |   app/controllers/concerns/foreman/controller/parameters/keep_param.rb:10:in `each'
 |   app/controllers/concerns/foreman/controller/parameters/keep_param.rb:10:in `inject'
 |   app/controllers/concerns/foreman/controller/parameters/keep_param.rb:10:in `keep_param'
 |   app/controllers/concerns/foreman/controller/parameters/host.rb:34:in `host_params'
 |   app/controllers/concerns/foreman/controller/host_details.rb:58:in `item_params'
 |   app/controllers/concerns/foreman/controller/host_details.rb:50:in `block in assign_parameter'
 |   app/models/taxonomy.rb:72:in `block (2 levels) in as_taxonomy'
 |   app/models/concerns/foreman/thread_session.rb:150:in `as_location'
 |   app/models/taxonomy.rb:71:in `block in as_taxonomy'
 |   app/models/concerns/foreman/thread_session.rb:115:in `as_org'
 |   app/models/taxonomy.rb:70:in `as_taxonomy'
 |   app/controllers/concerns/foreman/controller/host_details.rb:49:in `assign_parameter'
 |   app/controllers/concerns/foreman/controller/host_details.rb:8:in `architecture_selected'
 |   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'
 |   lib/middleware/catch_json_parse_errors.rb:8:in `call'
 |   lib/middleware/tagged_logging.rb:18:in `call'
 | 


Related issues

Related to Foreman - Feature #3917: Add strong_parameters to foreman Closed 12/19/2013

Associated revisions

Revision d14f17f6
Added by Tomer Brisker 4 months ago

Fixes #19417 - Safely check params for nested keys

History

#1 Updated by The Foreman Bot 4 months ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Tomer Brisker
  • Pull request https://github.com/theforeman/foreman/pull/4491 added

#2 Updated by Dominic Cleal 4 months ago

  • Category set to Rails

#3 Updated by Anonymous 4 months ago

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

#4 Updated by Tomer Brisker 4 months ago

  • Release set to 1.15.0

Setting this to 1.15.0 since discovery (and possibly other plugins) would be broken otherwise.

#5 Updated by Dominic Cleal 4 months ago

This doesn't look like a regression, keep_param has always expected the top level hash ever since commit 1261280. Why is it any different in 1.15.0?

#6 Updated by Tomer Brisker 4 months ago

  • Related to Feature #3917: Add strong_parameters to foreman added

#7 Updated by Tomer Brisker 4 months ago

It's possible this has actually been broken for a while but hasn't been discovered yet due to lack of tests.

#8 Updated by Dominic Cleal 4 months ago

  • Release deleted (1.15.0)

I'll unset the field then, and let a release manager set it to a future bug fix release then. It missed 1.15.0 and doesn't appear to be a regression in the current RCs.

#9 Updated by Tomer Brisker 4 months ago

Further digging led me to find #19436 which, which is what caused this issue to appear (sending discovered_host param to the hosts controller instead of the host controller). I agree this fix can wait for next release, the other one is a regression though.

#10 Updated by Daniel Lobato Garcia about 1 month ago

  • Release set to 1.15.3

#11 Updated by Daniel Lobato Garcia about 1 month ago

Setting to 1.15.3 as Raboo on IRC comments this is blocking the discovery workflow in their installation

Also available in: Atom PDF