Bug #13704

Error when updating host location by name through API

Added by David Barbion almost 2 years ago. Updated about 1 year ago.

Status:Closed
Priority:Normal
Assigned To:Shlomi Zadok
Category:API
Target version:Team Marek Iteration 3
Difficulty: Bugzilla link:1379006
Found in release:1.10.1 Pull request:https://github.com/theforeman/foreman/pull/3851
Story points-
Velocity based estimate-
Release1.13.1Release relationshipAuto

Description

Hi,

I would like to update a host location by providing "location_name" by it results in error: Here is a simple curl command I use:

$ curl -s -X PUT -H "Content-Type: application/json" -k -u hammer:hammer \
  -d '{"host": { "location_name": "mag003"}}' \
  https://foreman.example.com/api/hosts/host.example.com
{
  "error": {"message":"undefined method `id' for nil:NilClass"}
}

When I provide "location_id", it works.

production.log - Backtrace of error (13.5 KB) David Barbion, 02/15/2016 06:15 AM


Related issues

Related to Foreman - Bug #16813: Confusing error message on association not found error Closed 10/06/2016

Associated revisions

Revision 65af0932
Added by Shlomi Zadok about 1 year ago

Fixes #13704 - Defensive association name setter
When setting an association by name
(e.g., hostgroup_name, organization_name)
and the name does not exist, we raise a not found error

Revision 872acf80
Added by Shlomi Zadok about 1 year ago

Fixes #13704 - Defensive association name setter
When setting an association by name
(e.g., hostgroup_name, organization_name)
and the name does not exist, we raise a not found error

(cherry picked from commit 65af0932ee5ed8cf9a1ad1ac3c55958fcea77ab7)

History

#1 Updated by David Barbion almost 2 years ago

This problem occurs when providing an inexistent location.

In my case, it works if I provide full location_name:

curl -s -X PUT -H "Content-Type: application/json" -k -u hammer:hammer \
  -d '{"host": { "location_name": "Full/path/to/mag003"}}' \
  https://foreman.example.com/api/hosts/host.example.com

#2 Updated by The Foreman Bot over 1 year ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Shlomi Zadok
  • Pull request https://github.com/theforeman/foreman/pull/3851 added

#3 Updated by Shlomi Zadok over 1 year ago

  • Target version set to Team Marek Iteration 3

#4 Updated by Shlomi Zadok about 1 year ago

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

#5 Updated by Dominic Cleal about 1 year ago

  • Release set to 1.13.1

#6 Updated by Marek Hulán about 1 year ago

  • Related to Bug #16813: Confusing error message on association not found error added

#7 Updated by Marek Hulán about 1 year ago

  • Bugzilla link set to 1379006

Also available in: Atom PDF