From c4a87b753f09306436ba0c787669bc6a28b7edb5 Mon Sep 17 00:00:00 2001 From: Shahar Glazner Date: Mon, 18 Mar 2024 14:34:17 +0200 Subject: [PATCH] fix: validation (#975) --- keep/api/routes/workflows.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/keep/api/routes/workflows.py b/keep/api/routes/workflows.py index c27c545bd..f4ae01077 100644 --- a/keep/api/routes/workflows.py +++ b/keep/api/routes/workflows.py @@ -184,13 +184,20 @@ def run_workflow( # Finally, run it try: # if its event that was triggered by the UI with the Modal - if "test-workflow" in body.get("fingerprint", ""): + if "test-workflow" in body.get("fingerprint", "") or not body: # some random - body["id"] = body.get("fingerprint") + body["id"] = body.get("fingerprint", "manual-run") + body["name"] = body.get("fingerprint", "manual-run") body["lastReceived"] = datetime.datetime.now( tz=datetime.timezone.utc ).isoformat() - alert = AlertDto(**body) + try: + alert = AlertDto(**body) + except TypeError: + raise HTTPException( + status_code=400, + detail="Invalid alert format", + ) workflow_execution_id = workflowmanager.scheduler.handle_manual_event_workflow( workflow_id, tenant_id, created_by, alert )