Project

General

Profile

Actions

Bug #6375

closed

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

Added by Marek Hulán almost 10 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
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 2 (0 open2 closed)

Related to Foreman - Bug #5129: Host Group creation may fail if Host Group with id 1 exists with same parameter nameClosedJoseph Magen04/09/2014Actions
Related to Foreman - Refactor #14934: Remove Rails 3.2.8 workaround in parameter modelClosedTomer Brisker05/05/2016Actions
Actions

Also available in: Atom PDF