Project

General

Profile

Actions

Bug #35825

open

Payload crashes if object returns nil

Added by Jonas Trüstedt over 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Using a template like:

<%=
payload({
id: @object.id,
name: @object.name,
organization: @object.organization.name,
ip: [ @object.ip, @object.ip6 ],
description: @object.comment,
hostgroup: @object.hostgroup
})
-%>

The webhook/payload-function crashes if the host targeted has no hostgroup with a message that it cannot 'render' for nil:NilClass.
You can workaround that by casting that into a string with:

hostgroup: @object.hostgroup.to_s

But in that case if the hostgroup is not set it will just return an empty string and something like "null" would be better.

Version used is Foreman 3.1 with Webhooks-Plugin 3.0

No data to display

Actions

Also available in: Atom PDF