From 40d56448955a3675537efd8278a1c3027633987a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20Zar=C4=99bski?= Date: Thu, 12 Jun 2025 13:08:34 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20bug=20when=20threshold?= =?UTF-8?q?=20or=20alert=20range=20of=20zero=20specified?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ simvue/api/objects/alert/fetch.py | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72545e26..d6993bb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ # Change log +## Unreleased +* Fixed bug where if the range or threshold of an alert is zero the alert type validation fails. ## [v2.1.1](https://github.com/simvue-io/client/releases/tag/v2.1.1) - 2025-04-25 * Changed from CO2 Signal to ElectricityMaps * Fixed a number of bugs in how offline mode is handled with emissions diff --git a/simvue/api/objects/alert/fetch.py b/simvue/api/objects/alert/fetch.py index 05cc132d..cf7dae47 100644 --- a/simvue/api/objects/alert/fetch.py +++ b/simvue/api/objects/alert/fetch.py @@ -131,8 +131,9 @@ def get( _id, UserAlert(_read_only=True, identifier=_id, _local=True, **_entry), ) - elif _entry["source"] == "metrics" and _entry.get("alert", {}).get( - "threshold" + elif ( + _entry["source"] == "metrics" + and _entry.get("alert", {}).get("threshold") is not None ): yield ( _id, @@ -140,8 +141,9 @@ def get( _local=True, _read_only=True, identifier=_id, **_entry ), ) - elif _entry["source"] == "metrics" and _entry.get("alert", {}).get( - "range_low" + elif ( + _entry["source"] == "metrics" + and _entry.get("alert", {}).get("range_low") is not None ): yield ( _id,