diff --git a/orchestrator/handlers/handler.go b/orchestrator/handlers/handler.go index 1837c047..df5b34aa 100644 --- a/orchestrator/handlers/handler.go +++ b/orchestrator/handlers/handler.go @@ -2,6 +2,7 @@ package handlers import ( "encoding/json" + // "fmt" "net/http" "strconv" "time" @@ -121,6 +122,7 @@ func (h *Handler) RestartStateMachine(c *gin.Context) { // Fetch the workflow definition from the database active_wf_record, err := h.api.FetchActiveWorkflow(active_wf_id) + // fmt.Println("Error: ",active_wf_record) if err != nil { h.logger.Error("Error fetching workflow definition") c.JSON(http.StatusInternalServerError, gin.H{ @@ -129,6 +131,13 @@ func (h *Handler) RestartStateMachine(c *gin.Context) { return } + if active_wf_record.ID == 0 { + c.JSON(http.StatusBadRequest, gin.H{ + "error": "Invalid workflow ID", + }) + return + } + // Unmarshal the workflow definition var wf workflow.Workflow err = json.Unmarshal([]byte(active_wf_record.WorkflowInstance), &wf)