Project

General

Profile

Bug #6375

Can't create parameters for operating system with id 1 using API

Added by Marek Hulán about 5 years ago. Updated about 1 year ago.

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

Description

When you try to create a new parameter for operating system with id 1, you result in 422 error

Started POST "/api/operatingsystems/1/parameters" for 192.168.122.22 at 2014-06-25 08:46:15 +0000
Processing by Api::V2::ParametersController#create as JSON
  Parameters: {"parameter"=>{"value"=>"[FILTERED]", "name"=>"ssh_public_key"}, "apiv"=>"v2", "operatingsystem_id"=>"1"}
Authorized user admin(Admin User)
Unprocessable entity OsParameter (id: new):
  Reference parameters require an associated domain, host or host group

  Rendered api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout (1.3ms)
Completed 422 Unprocessable Entity in 657ms (Views: 2.4ms | ActiveRecord: 299.7ms)

The issue is in that reference_id is set to nil (this is inspect of @parameter from create action)

#<OsParameter id: nil, name: "ssh_public_key", value: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5mX2JV6T6CVCRmT...", reference_id: nil, created_at: nil, updated_at: nil, type: "OsParameter", priority: 2>

git bisect found #5129 and 691f0a1a809569d125e9385e60f8f1e1c8d88061 as a source of the issue. It seems that for some reason we enforce nil for reference_id when it's set to 1. Related PR https://github.com/theforeman/foreman/pull/1504. Note that it was merged to 1.5.2


Related issues

Related to Foreman - Bug #5129: Host Group creation may fail if Host Group with id 1 exists with same parameter nameClosed2014-04-09
Related to Foreman - Refactor #14934: Remove Rails 3.2.8 workaround in parameter modelClosed2016-05-05

Associated revisions

Revision 5dded917 (diff)
Added by Joseph Magen about 5 years ago

fixes #6375 - fix needed for Rails 3.2.8 only that ensures reference_id on parameter.rb matches the nested object id

Revision 37af54e1 (diff)
Added by Joseph Magen about 5 years ago

fixes #6375 - fix needed for Rails 3.2.8 only that ensures reference_id on parameter.rb matches the nested object id

(cherry picked from commit 5dded9172adeadb8ef0f56a33787b213784551a4)

Revision 1d939ec0 (diff)
Added by Dominic Cleal about 5 years ago

refs #6375 - revert string change

History

#1 Updated by Marek Hulán about 5 years ago

  • Subject changed from Can't create parameters for operating systems using API to Can't create parameters for operating system with id 1 using API
  • Description updated (diff)

#2 Updated by Dominic Cleal about 5 years ago

  • Status changed from New to Assigned
  • Assignee set to Joseph Magen
  • Target version set to 1.8.1
  • Legacy Backlogs Release (now unused) set to 18

Thanks, that should've been obvious...

#3 Updated by Bryan Kearney about 5 years ago

  • Bugzilla link set to 1114640

#4 Updated by Dmitri Dolguikh about 5 years ago

  • Target version changed from 1.8.1 to 1.8.0

#5 Updated by Joseph Magen about 5 years ago

  • Status changed from Assigned to Ready For Testing

#6 Updated by Dominic Cleal about 5 years ago

  • Related to Bug #5129: Host Group creation may fail if Host Group with id 1 exists with same parameter name added

#7 Updated by Joseph Magen about 5 years ago

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

#8 Updated by The Foreman Bot about 5 years ago

  • Pull request https://github.com/theforeman/foreman/pull/1567 added

#9 Updated by Tomer Brisker over 3 years ago

  • Related to Refactor #14934: Remove Rails 3.2.8 workaround in parameter model added

Also available in: Atom PDF