Bug #6375

Updated by Marek Hulán almost 5 years ago

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

Started POST "/api/operatingsystems/1/parameters" for 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 Note that it was merged to 1.5.2