Project

General

Profile

Actions

Bug #6375

closed

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

Added by Marek Hulán over 10 years ago. Updated over 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 #1

Updated by Marek Hulán over 10 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)
Actions #2

Updated by Dominic Cleal over 10 years ago

  • Status changed from New to Assigned
  • Assignee set to Joseph Magen
  • Target version set to 1.8.1
  • Translation missing: en.field_release set to 18

Thanks, that should've been obvious...

Actions #3

Updated by Bryan Kearney over 10 years ago

  • Bugzilla link set to 1114640
Actions #4

Updated by Anonymous over 10 years ago

  • Target version changed from 1.8.1 to 1.8.0
Actions #5

Updated by Joseph Magen over 10 years ago

  • Status changed from Assigned to Ready For Testing
Actions #6

Updated by Dominic Cleal over 10 years ago

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

Updated by Joseph Magen over 10 years ago

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

Updated by The Foreman Bot over 10 years ago

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

Updated by Tomer Brisker over 8 years ago

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

Also available in: Atom PDF