Project

General

Profile

Bug #10550

Settings API updates value even if value parameter isn't supplied

Added by Dominic Cleal over 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Category:
Settings
Target version:
Difficulty:
easy
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

When making a PUT to /api/v2/settings/name with an empty hash, the value is changed. Since #10402 this will change booleans to false, prior to that you might get an error about downcase!.

GET "/api/v2/settings/Parametrized_Classes_in_ENC" 
value is true

Now update:

2015-05-19 16:30:54 [I] Started PUT "/api/v2/settings/Parametrized_Classes_in_ENC" for 127.0.0.1 at 2015-05-19 16:30:54 +0100
2015-05-19 16:30:54 [I] Processing by Api::V2::SettingsController#update as JSON
2015-05-19 16:30:54 [I] Parameters: {"setting"=>{}, "apiv"=>"v2", "id"=>"Parametrized_Classes_in_ENC"}
2015-05-19 16:30:54 [D] (0.1ms) UPDATE "settings" SET "value" = '--- false
...
', "updated_at" = '2015-05-19 15:30:54.787404' WHERE "settings"."category" IN ('Setting::Puppet') AND "settings"."id" = 28

And the value has been changed to false.

https://github.com/theforeman/foreman/blob/1.8.0/app/controllers/api/v2/settings_controller.rb#L27 is updating the value without changing that params even contains a value.

Associated revisions

Revision ee464a8e (diff)
Added by Ondřej Pražák about 4 years ago

Fixes #10550 - Settings API will not update when value parameter is missing

Revision f3194059 (diff)
Added by Dominic Cleal about 4 years ago

refs #10550 - extract settings API error string

History

#1 Updated by The Foreman Bot about 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2556 added
  • Pull request deleted ()

#2 Updated by Ondřej Pražák about 4 years ago

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

#3 Updated by Dominic Cleal about 4 years ago

  • Assignee set to Ondřej Pražák
  • Legacy Backlogs Release (now unused) set to 63

Also available in: Atom PDF