{"action":"created","issue":{"url":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/340","repository_url":"https://api.github.com/repos/zalando-zmon/zmon-worker","labels_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/340/labels{/name}","comments_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/340/comments","events_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/340/events","html_url":"https://github.com/zalando-zmon/zmon-worker/issues/340","id":326540417,"number":340,"title":"Check that the return type of alert() is a boolean","user":{"login":"ovolynets","id":2162246,"avatar_url":"https://avatars0.githubusercontent.com/u/2162246?v=4","gravatar_id":"","url":"https://api.github.com/users/ovolynets","html_url":"https://github.com/ovolynets","followers_url":"https://api.github.com/users/ovolynets/followers","following_url":"https://api.github.com/users/ovolynets/following{/other_user}","gists_url":"https://api.github.com/users/ovolynets/gists{/gist_id}","starred_url":"https://api.github.com/users/ovolynets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ovolynets/subscriptions","organizations_url":"https://api.github.com/users/ovolynets/orgs","repos_url":"https://api.github.com/users/ovolynets/repos","events_url":"https://api.github.com/users/ovolynets/events{/privacy}","received_events_url":"https://api.github.com/users/ovolynets/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-25T14:12:03Z","updated_at":"2018-05-25T15:27:27Z","closed_at":null,"author_association":"NONE","body":"I noticed that some check do not do their job if the return value of the `alert()` function was not a boolean, e.g.:\r\n\r\n```\r\ndef alert():\r\n    rps = value['some_url']['requests_per_sec']\r\n    capture(rps=rps) < 0.005\r\n```\r\n\r\nwhich does evaluate the capture and the comparison but does not return the `boolean` value required to trigger the check. The right function should look like\r\n\r\n```\r\ndef alert():\r\n    rps = value['some_url']['requests_per_sec']\r\n    return capture(rps=rps) < 0.005\r\n```\r\nWhen using the simple syntax for the alert (i.e. skipping `def alert()`), this would work just fine:\r\n```\r\ncapture(rps=value['some_url']['requests_per_sec']) < 0.005\r\n```\r\ntherefore it is also tricky when extending simple checks: it is easy to forget about the return.\r\nIt would be nice to return an error if the type of the returned value is `None`"},"comment":{"url":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/comments/392093939","html_url":"https://github.com/zalando-zmon/zmon-worker/issues/340#issuecomment-392093939","issue_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/340","id":392093939,"user":{"login":"hjacobs","id":510328,"avatar_url":"https://avatars3.githubusercontent.com/u/510328?v=4","gravatar_id":"","url":"https://api.github.com/users/hjacobs","html_url":"https://github.com/hjacobs","followers_url":"https://api.github.com/users/hjacobs/followers","following_url":"https://api.github.com/users/hjacobs/following{/other_user}","gists_url":"https://api.github.com/users/hjacobs/gists{/gist_id}","starred_url":"https://api.github.com/users/hjacobs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hjacobs/subscriptions","organizations_url":"https://api.github.com/users/hjacobs/orgs","repos_url":"https://api.github.com/users/hjacobs/repos","events_url":"https://api.github.com/users/hjacobs/events{/privacy}","received_events_url":"https://api.github.com/users/hjacobs/received_events","type":"User","site_admin":false},"created_at":"2018-05-25T15:27:27Z","updated_at":"2018-05-25T15:27:27Z","author_association":"MEMBER","body":"@ovolynets thanks for reporting! I think it's just a matter of changing the type conversion and explicitly disallow `None` (`bool(None)` evaluates to `False`): https://github.com/zalando-zmon/zmon-worker/blob/master/zmon_worker_monitor/zmon_worker/tasks/main.py#L1439"}}
{"actor":{"display_login":"hjacobs"}}