From 6125413a33464bca9fe3a57dce0c2de028904f4a Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 10 Nov 2025 19:34:25 +0100 Subject: [PATCH] Handle KeyError in CheckInitialChangeSymbols We don't want KeyErrors in petablint output. --- petab/v2/lint.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/petab/v2/lint.py b/petab/v2/lint.py index 178abc79..1fe83144 100644 --- a/petab/v2/lint.py +++ b/petab/v2/lint.py @@ -768,8 +768,15 @@ def run(self, problem: Problem) -> ValidationIssue | None: if condition_id in valid_conditions: continue - # we assume that all referenced condition IDs are valid - condition = id_to_condition[condition_id] + try: + condition = id_to_condition[condition_id] + except KeyError: + messages.append( + f"Unable to validate changes for condition " + f"{condition_id} applied at the start of " + f"experiment {experiment.id}, as the condition " + "does not exist." + ) used_symbols = { str(sym)