From d657c0285a3552c0576d477f5da152ea5c9c9c72 Mon Sep 17 00:00:00 2001 From: jebus Date: Thu, 23 Jul 2026 07:45:36 +1200 Subject: [PATCH] [Fix] Catch invalid reactions smiles on reaction creation (#431) Co-authored-by: Tim Lorsbach Reviewed-on: https://git.envipath.com/enviPath/enviPy/pulls/431 --- epdb/views.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/epdb/views.py b/epdb/views.py index d6e54dd2..a4db722e 100644 --- a/epdb/views.py +++ b/epdb/views.py @@ -1918,6 +1918,21 @@ def package_reactions(request, package_uuid): reaction_name = request.POST.get("reaction-name") reaction_description = request.POST.get("reaction-description") reaction_smiles = request.POST.get("reaction-smiles") + + if reaction_smiles is None or reaction_smiles.strip() == "": + return error( + request, + "Reaction SMILES is empty / missing", + "No reaction SMILES provided. Please provide a SMILES for the reaction.", + ) + + if not FormatConverter.is_valid_smirks(reaction_smiles): + return error( + request, + "Reaction SMILES is invalid", + f"The provided reactions SMILES {reaction_smiles} is invalid", + ) + educts = reaction_smiles.split(">>")[0].split(".") products = reaction_smiles.split(">>")[1].split(".")