Project

General

Profile

Actions

Bug #1608

closed

REST API calls /hosts/:id/puppetclasses fails for hosts with no class and no hostgroup

Added by Florent Castelli almost 12 years ago. Updated almost 12 years ago.

Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Extract from the logs:

Hostgroup Load (0.9ms)  SELECT DISTINCT puppetclasses.id FROM "hostgroups" INNER JOIN "hosts" ON "hosts"."hostgroup_id" = "hostgroups"."id" INNER JOIN "hostgroups_puppetclasses" ON "hostgroups_puppetclasses"."hostgroup_id" = "hostgroups"."id" INNER JOIN "puppetclasses" ON "puppetclasses"."id" = "hostgroups_puppetclasses"."puppetclass_id" WHERE (hosts.name = 'somehost')
Puppetclass Load (0.6ms) SELECT name, id FROM "puppetclasses" WHERE ((puppetclasses.id = 'nil'))
PG::Error: ERROR: invalid input syntax for integer: "nil"
LINE 1: ..., id FROM "puppetclasses" WHERE ((puppetclasses.id = 'nil'))
^
: SELECT name, id FROM "puppetclasses" WHERE ((puppetclasses.id = 'nil'))
Operation FAILED: PG::Error: ERROR: invalid input syntax for integer: "nil"
LINE 1: ..., id FROM "puppetclasses" WHERE ((puppetclasses.id = 'nil'))
^
: SELECT name, id FROM "puppetclasses" WHERE ((puppetclasses.id = 'nil'))
app/controllers/puppetclasses_controller.rb:22:in `index'
app/controllers/puppetclasses_controller.rb:17:in `index'
Completed 500 Internal Server Error in 25ms

Suggested fix is to change in app/models/puppetclass.rb the condition "puppetclasses.id = 'nil'" to "1=0" to produce a valid false statement.
There's maybe a more portable way of producing a false statement, but I know for sure that sqlite doesn't support "false".


Related issues 1 (0 open1 closed)

Has duplicate Foreman - Bug #1609: REST API calls /hosts/:id/puppetclasses fails for hosts with same class assigned directly and through host groupClosedOhad Levy05/09/2012Actions
Actions #1

Updated by Ohad Levy almost 12 years ago

  • Status changed from New to Duplicate
Actions

Also available in: Atom PDF