Skip to content

Commit

Permalink
fix: bug that cause error 500
Browse files Browse the repository at this point in the history
  • Loading branch information
CaelanHill committed Sep 27, 2024
1 parent 3544be3 commit 36280cb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions orchestrator/handlers/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handlers

import (
"encoding/json"
// "fmt"
"net/http"
"strconv"
"time"
Expand Down Expand Up @@ -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{
Expand All @@ -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)
Expand Down

0 comments on commit 36280cb

Please sign in to comment.