From 050c2b76725770ef504f1db5d691d61faa9578b2 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Wed, 25 Mar 2026 18:19:52 +0000 Subject: [PATCH] Verify properties and actions exist before making controls and buttons. --- src/openflexure_microscope_server/ui.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/openflexure_microscope_server/ui.py b/src/openflexure_microscope_server/ui.py index 4620cab2..33134247 100644 --- a/src/openflexure_microscope_server/ui.py +++ b/src/openflexure_microscope_server/ui.py @@ -224,6 +224,8 @@ def action_button_for(thing: lt.Thing, action_name: str, **kwargs: Any) -> Actio :return: An ActionButton (Pydantic Model) object with all the information the webapp needs to create the action button. """ + if action_name not in thing.actions: + raise AttributeError(f"{thing.name} has no action {action_name}") return ActionButton(thing=thing.name, action=action_name, **kwargs) @@ -283,6 +285,8 @@ def property_control_for( """ if "label" not in kwargs: kwargs["label"] = property_name + if property_name not in thing.properties: + raise AttributeError(f"{thing.name} has no property {property_name}") return PropertyControl(thing=thing.name, property_name=property_name, **kwargs)