From 269efc483e09aa24d00be25330a5ab8e682a3694 Mon Sep 17 00:00:00 2001 From: Frikky Date: Tue, 3 Sep 2024 15:48:54 +0200 Subject: [PATCH] Fixed a single subflow with wait for result missing execution ID with cache --- shared.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/shared.go b/shared.go index fd51588..265683f 100755 --- a/shared.go +++ b/shared.go @@ -14019,13 +14019,43 @@ func updateExecutionParent(ctx context.Context, executionParent, returnValue, pa sendRequest = true } else { // In here maning no-loop? + /* actionValue := SubflowData{ Success: true, ExecutionId: executionParent, Authorization: parentAuth, Result: returnValue, } + */ + + actionValue := SubflowData{ + Success: true, + ExecutionId: "", + Authorization: "", + Result: returnValue, + } + + newCacheKey := fmt.Sprintf("%s_%s_sinkholed_result", executionParent, parentNode) + cacheData, err := GetCache(ctx, newCacheKey) + if err != nil { + log.Printf("[ERROR] Failed setting cache for subflow action result %s (4): %s", subflowExecutionId, err) + } else { + mappedData, ok := cacheData.([]byte) + if ok { + // Unmarshal it into actionValue + err = json.Unmarshal(mappedData, &actionValue) + if err != nil { + log.Printf("[ERROR] Failed unmarshalling cache for subflow action result %s (4): %s", subflowExecutionId, err) + } + } else { + log.Printf("[ERROR] Failed type assertion for subflow action result %s (4): %s", subflowExecutionId, err) + } + } + + // Keep the original info + // Where is it kept? :thinking: + actionValue.Result = returnValue parsedActionValue, err := json.Marshal(actionValue) if err != nil { log.Printf("[ERROR] Failed updating resultData (1): %s", err) @@ -15450,6 +15480,14 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut log.Printf("[WARNING][%s] Sinkholing request of %s IF the subflow-result DOESNT have result.", workflowExecution.ExecutionId, actionResult.Action.Label) + // Just set the sinkholed data for some time in cache in case + // it will be necessary to use later. E.g. for wait for results + // + subflow data + newCacheKey := fmt.Sprintf("%s_%s_sinkholed_result", workflowExecution.ExecutionId, actionResult.Action.ID) + go SetCache(ctx, newCacheKey, []byte(actionResult.Result), 35) + + + if jsonerr == nil && len(subflowData.Result) == 0 && !strings.Contains(actionResult.Result, "\"result\"") { log.Printf("[INFO][%s] NO RESULT FOR SUBFLOW RESULT - SETTING TO EXECUTING. Results: %d. Trying to find subexec in cache onprem", workflowExecution.ExecutionId, len(workflowExecution.Results))