Skip to content

Commit

Permalink
Wrote a workflow loader override to (hopefully) help with the subflow…
Browse files Browse the repository at this point in the history
… execution problem that returns 500s
  • Loading branch information
frikky committed Aug 9, 2024
1 parent 0c65a33 commit aac319b
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -19375,6 +19375,40 @@ func DownloadFromUrl(ctx context.Context, url string) ([]byte, error) {

// New execution with firestore
func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *http.Request, maxExecutionDepth int64) (WorkflowExecution, ExecInfo, string, error) {
// Check the URL for the workflow ID itself
if request != nil { // && len(workflow.Actions) == 0 {

// Parse out the the workflow ID from the url
splitUrl := strings.Split(request.URL.Path, "/")
if len(splitUrl) == 6 {
foundId := splitUrl[4]

if len(foundId) == 36 {
if workflow.ID != foundId {
log.Printf("[DEBUG] Updating Workflow ID from '%s' to '%s'", workflow.ID, foundId)
workflow.ID = foundId
}

newWorkflow, err := GetWorkflow(ctx, workflow.ID)
if err == nil && len(newWorkflow.ID) == 36 && len(newWorkflow.Actions) > 0 {
workflow = *newWorkflow
}
}
}
}

// Try again if there is no request available? These are backups if we don't have the data
if len(workflow.ID) == 36 && len(workflow.Actions) == 0 {
newWorkflow, err := GetWorkflow(ctx, workflow.ID)
if err != nil {
log.Printf("[WARNING] Failed getting workflow for execution: %s", err)
} else {
if len(newWorkflow.ID) > 0 && len(newWorkflow.Actions) > 0 {
workflow = *newWorkflow
}
}
}

workflowBytes, err := json.Marshal(workflow)
if err != nil {
log.Printf("[WARNING] Failed workflow unmarshal in execution: %s", err)
Expand Down Expand Up @@ -28099,8 +28133,8 @@ func checkExecutionStatus(ctx context.Context, exec *WorkflowExecution) *Workflo
unmarshalledHttp := HTTPOutput{}
err := json.Unmarshal([]byte(result.Result), &unmarshalledHttp)
if err != nil {
log.Printf("[ERROR] Failed unmarshalling http result for %s: %s", result.Action.Label, err)
continue
//log.Printf("[WARNING] Failed unmarshalling http result for %s: %s", result.Action.Label, err)
//continue
}

isValid := false
Expand Down

0 comments on commit aac319b

Please sign in to comment.