Modify/manage Servicesets -> Services => error: Call to a member function toString()

Status
upgraded a 4.5 years old Icinga implementation to latest versions (incl. modules, libs, schema updates) all in one (was not my basic intention…).
used not any master branch, only stable tags.
all upgrade objects fine, except Director → Services → Servicesets → Services

would appreciate any hint or even a (temp) solution.
tx, Manfred

Expected Behavior
let correctly modify/manage/store Director → Services → Servicesets → Services

Current Behavior / Problem
when trying to manage Servicesets → Services in most (not all !) cases this error bailes out:


Uncaught Error: Call to a member function toString() on null in /usr/share/icingaweb2/modules/director/application/controllers/ServiceController.php:254
Stack trace:
#0 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(497): Icinga\Module\Director\Controllers\ServiceController->loadObject()
#1 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(90): Icinga\Module\Director\Web\Controller\ObjectController->loadOptionalObject()
#2 /usr/share/icingaweb2/modules/director/application/controllers/ServiceController.php(46): Icinga\Module\Director\Web\Controller\ObjectController->init()
#3 /usr/share/php/Icinga/Web/Controller/ActionController.php(165): Icinga\Module\Director\Controllers\ServiceController->init()
#4 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(59): Icinga\Web\Controller\ActionController->__construct(Object(Icinga\Web\Request), Object(Icinga\Web\Response), Array)
#5 /usr/share/icingaweb2/library/vendor/Zend/Controll

#0 [internal function]: Icinga\Application\Web->Icinga\Application\{closure}()
#1 {main}

Environment


browser = google chrome
# icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: 2.13.2-1)
System information:
  Platform: Red Hat Enterprise Linux Server
  Platform version: 7.9 (Maipo)
  Kernel: Linux
  Kernel version: 3.10.0-1160.59.1.el7.x86_64
  Architecture: x86_64
Build information:
  Compiler: GNU 4.8.5
  Build host: runner-hh8q3bz2-project-322-concurrent-0
  OpenSSL version: OpenSSL 1.0.2k-fips  26 Jan 2017

# icingacli --version
Icinga Web 2  2.9.5
Git Commit    053971c99dc1a4510beb64a888ea695cc14032dc
PHP Version   7.3.29
MODULE       VERSION
director     1.9.0
doc          2.9.5
grafana      1.4.2
incubator    0.13.0
monitoring   2.9.5
setup        2.9.5
translation  2.9.5

err-2

err-3

Looks like you are hitting: Bug: Director 1.9.0 API - GET director/service?name=... returns Call to a member function toString() on null (Http code 500) · Issue #2487 · Icinga/icingaweb2-module-director · GitHub

(tx for quick reply)
yes, I also think it is very close. I already experimented yesterday with this part of the PHP code.
I changed this ‘HOT FIX’ part in various ways, but either the same error popped up or some other.
anyway, this part of the function ‘loadObject’ seems to be the target of intensive research.
sometimes for some objects it works as expected, so the return of $uuid is valid an translatable toString() - leading to a valid form to let modify the service object.
but in more other (error-) cases the return of $uuid seems somehow invalid an NOT translatable toString() - leading to the stack trace.

now I even tried every single commit top down from last master commit (yes, absolutely not recommended) down to tag 1.9.0 – sadly with no success.

I just hit the same issue and the hot fix mentioned in #2487 also didn’t work for me, but I noticed another detail and the workaround works now here, see this comment.

2 Likes

thanks berrnd,
this is an excellent pointer!
I combined now both fixes - and it seems to work for me!
I will watch & post if side-effects are popping up, but currently we can continue to manage those sets.

        // --- HOT FIX #1: search for type template too
        if(is_null($uuid)){
                $uuid = UuidLookup::findServiceUuid($this->db(), $this->getBranch(), 'template', $key, $this->host, $this->set);
        }
        // --- /FIX

        // --- FIX #2 : search for type 'apply' also
        if(is_null($uuid)){
                $uuid = UuidLookup::findServiceUuid($this->db(), $this->getBranch(), 'apply', $key, $this->host, $this->set);
        }
        // ---