Fixed an app creator file bug and added execution testing to workflow

This commit is contained in:
frikky
2022-10-09 15:37:41 +02:00
parent a4ee887245
commit bd170df0f0
13 changed files with 856 additions and 290 deletions
+91
View File
@@ -2166,10 +2166,87 @@ class AppBase:
self.logger.info(f"[ERROR] Liquid Template error: {e}")
error = True
error_msg = e
self.action["parameters"].append({
"name": "liquid_template_error",
"value": f"There was a Liquid input error (1). Details: {e}",
})
self.action_result["action"] = self.action
except SyntaxError as e:
self.logger.info(f"[ERROR] Liquid Syntax error: {e}")
error = True
error_msg = e
self.action["parameters"].append({
"name": "liquid_python_syntax_error",
"value": f"There was a syntax error in your Liquid input (2). Details: {e}",
})
self.action_result["action"] = self.action
except IndentationError as e:
self.logger.info(f"[ERROR] Liquid IndentationError: {e}")
error = True
error_msg = e
self.action["parameters"].append({
"name": "liquid_indentiation_error",
"value": f"There was an indentation error in your Liquid input (2). Details: {e}",
})
self.action_result["action"] = self.action
except jinja2.exceptions.TemplateSyntaxError as e:
self.logger.info(f"[ERROR] Liquid Syntax error: {e}")
error = True
error_msg = e
self.action["parameters"].append({
"name": "liquid_syntax_error",
"value": f"There was a syntax error in your Liquid input (2). Details: {e}",
})
self.action_result["action"] = self.action
except json.decoder.JSONDecodeError as e:
self.logger.info(f"[ERROR] Liquid JSON Syntax error: {e}")
replace = False
skip_next = False
newlines = []
thisline = []
for line in template.split("\n"):
#print("LINE: %s" % repr(line))
if "\"\"\"" in line or "\'\'\'" in line:
if replace:
skip_next = True
else:
replace = not replace
if replace == True:
thisline.append(line)
if skip_next == True:
if len(thisline) > 0:
#print(thisline)
newlines.append(" ".join(thisline))
thisline = []
replace = False
else:
newlines.append(line)
new_template = "\n".join(newlines)
if new_template != template:
#check_template(new_template)
return parse_liquid(new_template, self)
else:
error = True
error_msg = e
self.action["parameters"].append({
"name": "liquid_json_error",
"value": f"There was a syntax error in your input JSON(2). This is typically an issue with escaping newlines. Details: {e}",
})
self.action_result["action"] = self.action
except TypeError as e:
try:
if "string as left operand" in f"{e}":
@@ -2194,6 +2271,13 @@ class AppBase:
except Exception as e:
print(f"SubError in Liquid: {e}")
self.action["parameters"].append({
"name": "liquid_general_error",
"value": f"There was general error Liquid input (2). Details: {e}",
})
self.action_result["action"] = self.action
#return template
self.logger.info(f"[ERROR] Liquid TypeError error: {e}")
@@ -2205,6 +2289,13 @@ class AppBase:
error = True
error_msg = e
self.action["parameters"].append({
"name": "liquid_general_exception",
"value": f"There was general exception Liquid input (2). Details: {e}",
})
self.action_result["action"] = self.action
if "fmt" in error_msg and "liquid_date" in error_msg:
return template
+34
View File
@@ -395,6 +395,40 @@ func handleGetStreamResults(resp http.ResponseWriter, request *http.Request) {
}
}
for _, action := range workflowExecution.Workflow.Actions {
found := false
for _, result := range workflowExecution.Results {
if result.Action.ID == action.ID {
found = true
break
}
}
if found {
continue
}
//log.Printf("[DEBUG] Maybe not handled yet: %s", action.ID)
cacheId := fmt.Sprintf("%s_%s_result", workflowExecution.ExecutionId, action.ID)
cache, err := shuffle.GetCache(ctx, cacheId)
if err != nil {
//log.Printf("[WARNING] Couldn't find in fix exec %s (2): %s", cacheId, err)
continue
}
actionResult := shuffle.ActionResult{}
cacheData := []byte(cache.([]uint8))
// Just ensuring the data is good
err = json.Unmarshal(cacheData, &actionResult)
if err != nil {
continue
} else {
log.Printf("[DEBUG] APPENDING %s result to send to app or something\n\n\n\n", action.ID)
workflowExecution.Results = append(workflowExecution.Results, actionResult)
}
}
newjson, err := json.Marshal(workflowExecution)
if err != nil {
resp.WriteHeader(401)