Describe the bug
The error is when trying to amend/update an icinga director service. To do an amend first I query the current service object using:
icingacli director service show --host="aslf02" 'check_juniper_load' --json --no-pretty
which returns the json output, I would then modify the keys/values and then submit the change back. However when pushing back the change (for example even if I don't change any fields and push back exactly the same record) I get the error:
ERROR: InvalidArgumentException in /usr/share/icingaweb2/modules/director/library/Director/Data/Db/DbObject.php:364 with message: Trying to set invalid key "fields"
The "director service show" command returns:
icingacli director service show --host="aslf02" 'check_juniper_load' --json --no-pretty
{"fields":[],"host":"aslf02","imports":["servicetemplate-XXXX","service-juniper-load"],"notes":"Added by icinga-import 10:14:56 13/12/2024","object_name":"check_juniper_load","object_type":"object","uuid":"198e50ba-73d8-4be8-979f-fae427918a2b","vars":{"ARG1":"20,30,40"}}
You can see the first json array returned is "fields". This isn't being set in my code anywhere, it seems to be a default parameter added either by director or icinga.
So if I then submit that back I get the error returned as it's trying to set the key "fields" which it states to be invalid.
In previous versions of icinga/icingacli this didn't occur, however my other installation is a much older install so this may be a few revisions since this crept in.
icingacli version
Icinga Web 2 2.12.2
Git Commit 7f9217b0521f19f770ad59ca17d7d4b3514e54e5
PHP Version 8.1.2-1ubuntu2.19
MODULE VERSION
director 1.11.3
incubator 0.22.0
monitoring 2.12.2
pnp 1.0.1
pulsant-theme 1.0.1
(For reference, my older install uses 2.7.3 which doesn't appear to have this issue)
If I do an "inspect" via the GUI I see no reference of this key "fields".
Looking at the code, the export I suspect is adding this is here:
/usr/share/icingaweb2/modules/director/library/Director/Data/Exporter.php
protected function exportIcingaObject(IcingaObject $object)
{
$props = (array) $object->toPlainObject($this->resolveObjects, !$this->showDefaults);
if ($object->supportsFields()) {
$props['fields'] = $this->fieldReferenceLoader->loadFor($object);
}
return $props;
}
But I'm not clear if this should be exporting the property "fields" or not when it's clearly blank in my case?
Describe the bug
The error is when trying to amend/update an icinga director service. To do an amend first I query the current service object using:
icingacli director service show --host="aslf02" 'check_juniper_load' --json --no-pretty
which returns the json output, I would then modify the keys/values and then submit the change back. However when pushing back the change (for example even if I don't change any fields and push back exactly the same record) I get the error:
The "director service show" command returns:
You can see the first json array returned is "fields". This isn't being set in my code anywhere, it seems to be a default parameter added either by director or icinga.
So if I then submit that back I get the error returned as it's trying to set the key "fields" which it states to be invalid.
In previous versions of icinga/icingacli this didn't occur, however my other installation is a much older install so this may be a few revisions since this crept in.
icingacli version
Icinga Web 2 2.12.2
Git Commit 7f9217b0521f19f770ad59ca17d7d4b3514e54e5
PHP Version 8.1.2-1ubuntu2.19
MODULE VERSION
director 1.11.3
incubator 0.22.0
monitoring 2.12.2
pnp 1.0.1
pulsant-theme 1.0.1
(For reference, my older install uses 2.7.3 which doesn't appear to have this issue)
If I do an "inspect" via the GUI I see no reference of this key "fields".
Looking at the code, the export I suspect is adding this is here:
/usr/share/icingaweb2/modules/director/library/Director/Data/Exporter.php
But I'm not clear if this should be exporting the property "fields" or not when it's clearly blank in my case?