You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a filter expression does not match anything when, for example, creating a comment via the API, Icinga 2 returns a "500 Internal Server Error" instead of the expected "404 Not Found" as the result.
To Reproduce
Create some test hosts (e.g. test-host-0 ... test-host-9) and test services per host.
Create a sufficiently privileged test user (e.g. with "*" permission) on the Icinga 2 server
Run an API request (e.g. 'add-comment' for an existing host/service):
POST /v1/actions/add-comment HTTP/1.1
Accept: application/json
Authorization: Basic YWdncmVnYXRlZDpYb3QleWt5R3BPdG9wSGV4T3gldXFJcTROZ2loT0o0SzNOW3V3TDBnWVJdT2plTFY0cDNMUWk=
Content-Type: application/json; charset=utf-8
Host: 192.168.110.112:5665
Connection: close
User-Agent: Paw/3.1.10 (Macintosh; OS X/10.15.4) GCDHTTPRequest
Content-Length: 138
{"filter":"host.name==\"test-host-1\"&&service.name==\"test-service-1\"","author":"Test User","comment":"Test Comment","type":"Service"}
=> Works fine:
HTTP/1.1 200 OK
Server: Icinga/2.11.3-1
Content-Type: application/json
Content-Length: 263
{"results":[{"code":200.0,"legacy_id":21.0,"name":"test-host-1!test-service-1!8641bb23-a3ea-4372-88b9-4657761144c1","status":"Successfully added comment 'test-host-1!test-service-1!8641bb23-a3ea-4372-88b9-4657761144c1' for object 'test-host-1!test-service-1'."}]}
Now run the same API request with a non-existing service and/or host:
POST /v1/actions/add-comment HTTP/1.1
Accept: application/json
Authorization: Basic YWdncmVnYXRlZDpYb3QleWt5R3BPdG9wSGV4T3gldXFJcTROZ2loT0o0SzNOW3V3TDBnWVJdT2plTFY0cDNMUWk=
Content-Type: application/json; charset=utf-8
Host: 192.168.110.112:5665
Connection: close
User-Agent: Paw/3.1.10 (Macintosh; OS X/10.15.4) GCDHTTPRequest
Content-Length: 139
{"filter":"host.name==\"test-host-11\"&&service.name==\"test-service-1\"","author":"Test User","comment":"Test Comment","type":"Service"}
In accordance with the usual behaviour of the Icinga 2 API and REST services in general, I would expect a 404 error with a sensible error message ("No resource found" or something similar).
Your Environment
Version used (icinga2 --version):
[root@master2 ~]# icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: 2.11.3-1)
Copyright (c) 2012-2020 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl2.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
System information:
Platform: CentOS Linux
Platform version: 7 (Core)
Kernel: Linux
Kernel version: 3.10.0-1062.9.1.el7.x86_64
Architecture: x86_64
Build information:
Compiler: GNU 4.8.5
Build host: runner-LTrJQZ9N-project-322-concurrent-0
Application information:
General paths:
Config directory: /etc/icinga2
Data directory: /var/lib/icinga2
Log directory: /var/log/icinga2
Cache directory: /var/cache/icinga2
Spool directory: /var/spool/icinga2
Run directory: /run/icinga2
Old paths (deprecated):
Installation root: /usr
Sysconf directory: /etc
Run directory (base): /run
Local state directory: /var
Internal paths:
Package data directory: /usr/share/icinga2
State path: /var/lib/icinga2/icinga2.state
Modified attributes path: /var/lib/icinga2/modified-attributes.conf
Objects path: /var/cache/icinga2/icinga2.debug
Vars path: /var/cache/icinga2/icinga2.vars
PID path: /run/icinga2/icinga2.pid
The 500 error occurs also when I URLencode the parameters, or when I just use hosts, not services. I can reproduce it on any Icinga 2 instance I'm currently running.
The text was updated successfully, but these errors were encountered:
Describe the bug
When a filter expression does not match anything when, for example, creating a comment via the API, Icinga 2 returns a "500 Internal Server Error" instead of the expected "404 Not Found" as the result.
To Reproduce
=> Works fine:
=> This time, an error 500 is reported:
Expected behavior
In accordance with the usual behaviour of the Icinga 2 API and REST services in general, I would expect a 404 error with a sensible error message ("No resource found" or something similar).
Your Environment
icinga2 --version
):icinga2 daemon -C
):Additional context
The 500 error occurs also when I URLencode the parameters, or when I just use hosts, not services. I can reproduce it on any Icinga 2 instance I'm currently running.
The text was updated successfully, but these errors were encountered: