-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Director 1.9.0 API - GET director/service?name=... returns Call to a member function toString() on null (Http code 500) #2487
Comments
+1 |
I hit the same problem when trying to edit existing service set services (adding new services works). @axelhahn's hot fix above basically works for me (thanks!), but I noticed that my existing service set services (in table So changing the hot fix to search for if(is_null($uuid)){
$uuid = UuidLookup::findServiceUuid($this->db(), $this->getBranch(), 'apply', $key, $this->host, $this->set);
} |
Another rough fix could be to check explicitly for host or set params, and switch to template when not present. Also, a 'not found' could be thrown instead of the PHP errors, to make the API respond similarly to other failed object lookups.
|
#2487 (comment) solved it in my case |
@mwaldmueller: did you tweak the code, or change the type in your DB? |
I modified the code with this:
|
Thank you! |
The code modification doesn't work for templates.
|
Expected Behavior
Using director API with a GET to https://icinga2.example.com/icingaweb2/director/service?name=service-template_for_command returns a valid response.
Current Behavior
We updated our Icingaweb2 instance and our modules. With update to Director 1.7 --> 1.9 I get HTTP status code 500.
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()
#5 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch()
#6 /usr/share/php/Icinga/Application/Web.php(304): Zend_Controller_Front->dispatch()
#7 /usr/share/php/Icinga/Application/webrouter.php(107): Icinga\Application\Web->dispatch()
#8 /usr/share/icingaweb2/public/index.php(4): require_once('...')
#9 {main}
thrown
Possible Solution
/usr/share/icingaweb2/modules/director/application/controllers/ServiceController.php
loadObject loads the object from table icinga_service by filtering object_type='object'. But the service template is object_type='template'. The $uuid is empty and $uuid->toString() fails.
I stupidly added:
It works for me but is not a clean solution.
Maybe the problem is the database update and service templates need to be object_type='object'??
Steps to Reproduce (for bugs)
GET to https://icinga2.example.com/icingaweb2/director/service?name=service-template_for_command
Your Environment
icinga2 --version
): 2.13.2-1)The text was updated successfully, but these errors were encountered: