Skip to content

Commit d209a29

Browse files
authored
Handle KeyError in CheckInitialChangeSymbols (#459)
We don't want KeyErrors in petablint output.
1 parent d83ca2b commit d209a29

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

petab/v2/lint.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,15 @@ def run(self, problem: Problem) -> ValidationIssue | None:
768768
if condition_id in valid_conditions:
769769
continue
770770

771-
# we assume that all referenced condition IDs are valid
772-
condition = id_to_condition[condition_id]
771+
try:
772+
condition = id_to_condition[condition_id]
773+
except KeyError:
774+
messages.append(
775+
f"Unable to validate changes for condition "
776+
f"{condition_id} applied at the start of "
777+
f"experiment {experiment.id}, as the condition "
778+
"does not exist."
779+
)
773780

774781
used_symbols = {
775782
str(sym)

0 commit comments

Comments
 (0)