Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
2.01k stars 576 forks source link

bolean value for sticky in API action acknowledge-problem not accepted #5731

Closed xtruthx closed 7 years ago

xtruthx commented 7 years ago

The error raises during creating a acknowledge-problem with comment and setting stickyness with false or true.

[root@server scripts]# curl -k -s -X "POST" "https://localhost:5665/v1/actions/acknowledge-problem" -H "Accept: application/json" -H "Content-Type: application/json; charset=utf-8" -u user:$(cat /etc/icinga2/.apipw.conf) -d "{\"type\":\"Service\",\"filter\":\"host.name==\\\"servername\\\"&&service.name==\\\"timesync\\\"\",\"author\":\"itsmscript\",\"comment\":\"INC000002462799\",\"sticky\":\"false\"}" 

{
    "results": [
        {
            "code": 500.0,
            "status": "Action execution failed: 'Error: Can't convert 'false' to a floating point number.\n'."
        }
    ]
}
[root@server scripts]# curl -k -s -X "POST" "https://localhost:5665/v1/actions/acknowledge-problem" -H "Accept: application/json" -H "Content-Type: application/json; charset=utf-8" -u user:$(cat /etc/icinga2/.apipw.conf) -d "{\"type\":\"Service\",\"filter\":\"host.name==\\\"servername\\\"&&service.name==\\\"timesync\\\"\",\"author\":\"itsmscript\",\"comment\":\"INC000002462799\",\"sticky\":\"0\"}"

{
    "results": [
        {
            "code": 200.0,
            "status": "Successfully acknowledged problem for object 'servername!timesync'."
        }
    ]
}

Expected Behavior

That you are able to use True or False for the action option "sticky" as value and it will be converted/accepted.

Current Behavior

The API is not converting false or true and expect a floating number.

Steps to Reproduce (for bugs)

As described at the beginning

Context

This issue appears while creating a ticket in ITSM which gives a feedback as service acknowledge with comment back to the icinga2 core

Your Environment

NAME="Red Hat Enterprise Linux Server"
VERSION="7.4 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.4"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.4 (Maipo)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.4:GA:server"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.4
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="7.4"
Red Hat Enterprise Linux Server release 7.4 (Maipo)
Red Hat Enterprise Linux Server release 7.4 (Maipo)
cpe:/o:redhat:enterprise_linux:7.4:ga:server
gunnarbeutner commented 7 years ago

The sticky argument is documented as being a boolean value. This implies that the JSON value you specify has to be either true or false, or (for HTTP arguments) a numeric value.