Skip to content

Commit 352e08f

Browse files
committed
Fixed an issue with parameters not filling in properly
1 parent c50cfb4 commit 352e08f

File tree

1 file changed

+23
-58
lines changed

1 file changed

+23
-58
lines changed

shared.go

Lines changed: 23 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,15 +1731,11 @@ func AddAppAuthentication(resp http.ResponseWriter, request *http.Request) {
17311731
continue
17321732
}
17331733

1734-
//log.Printf("Field '%s' has secret. Replace with the real value", field.Key)
17351734
for _, existingField := range originalAuth.Fields {
17361735
if existingField.Key != field.Key {
17371736
continue
17381737
}
17391738

1740-
//log.Printf("Replacing field %s with value '%s'", field.Key, existingField.Value)
1741-
1742-
//field.Value = existingField.Value
17431739
appAuth.Fields[fieldIndex].Value = existingField.Value
17441740

17451741
if originalAuth.Encrypted {
@@ -8199,13 +8195,27 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
81998195
}
82008196
}
82018197

8198+
// This is weird and for sure wrong somehow
82028199
newParams := []WorkflowAppActionParameter{}
82038200
for _, param := range curappaction.Parameters {
82048201
paramFound := false
82058202

82068203
// Handles check for parameter exists + value not empty in used fields
82078204
for _, actionParam := range action.Parameters {
82088205
if actionParam.Name == param.Name {
8206+
8207+
newParamsContains := false
8208+
for _, newParam := range newParams {
8209+
if newParam.Name == actionParam.Name {
8210+
newParamsContains = true
8211+
break
8212+
}
8213+
}
8214+
8215+
if !newParamsContains {
8216+
newParams = append(newParams, actionParam)
8217+
}
8218+
82098219
continue
82108220
}
82118221

@@ -8292,32 +8302,25 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
82928302
log.Printf("[WARNING] Handling oauth2 app saving, hence not throwing warnings (2)")
82938303
//workflow.Errors = append(workflow.Errors, fmt.Sprintf("Debug: Handling one Oauth2 app (%s). May cause issues during initial configuration (2)", action.Name))
82948304
} else {
8295-
thisError := fmt.Sprintf("Parameter %s is required", param.Name)
8296-
action.Errors = append(action.Errors, thisError)
8305+
if param.Name == "call" && action.AppName == "Shuffle Tools" {
8306+
} else {
8307+
thisError := fmt.Sprintf("Parameter %s is required", param.Name)
8308+
action.Errors = append(action.Errors, thisError)
82978309

8298-
workflow.Errors = append(workflow.Errors, thisError)
8299-
action.IsValid = false
8310+
workflow.Errors = append(workflow.Errors, thisError)
8311+
action.IsValid = false
8312+
}
83008313
}
8301-
8302-
//newActions = append(newActions, action)
8303-
//resp.WriteHeader(401)
8304-
//resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Appaction %s with required param '%s' is empty."}`, action.Name, param.Name)))
8305-
//return
83068314
}
83078315
}
83088316

8309-
log.Printf("ACTION3: %#v: %d vs %d", action.Name, len(action.Parameters), len(newParams))
83108317
action.Parameters = newParams
83118318
newActions = append(newActions, action)
83128319
}
83138320

83148321
}
83158322
}
83168323

8317-
for _, action := range newActions {
8318-
log.Printf("ACTION6: %#v: %d", action.Name, len(action.Parameters))
8319-
}
8320-
83218324
for _, trigger := range workflow.Triggers {
83228325
if trigger.Status != "running" && trigger.TriggerType != "SUBFLOW" && trigger.TriggerType != "USERINPUT" {
83238326
errorInfo := fmt.Sprintf("Trigger %s needs to be started", trigger.Name)
@@ -8431,40 +8434,6 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
84318434

84328435
_ = found
84338436

8434-
/*
8435-
if !found {
8436-
timeNow := int64(time.Now().Unix())
8437-
authFields := []AuthenticationStore{}
8438-
for _, param := range outerapp.Authentication.Parameters {
8439-
authFields = append(authFields, AuthenticationStore{
8440-
Key: param.Name,
8441-
Value: "",
8442-
})
8443-
}
8444-
8445-
appAuth := AppAuthenticationStorage{
8446-
Active: true,
8447-
Label: fmt.Sprintf("default_%s", outerapp.Name),
8448-
Id: uuid.NewV4().String(),
8449-
App: outerapp,
8450-
Fields: authFields,
8451-
Usage: []AuthenticationUsage{},
8452-
WorkflowCount: 0,
8453-
NodeCount: 0,
8454-
OrgId: user.ActiveOrg.Id,
8455-
Created: timeNow,
8456-
Edited: timeNow,
8457-
}
8458-
8459-
err = SetWorkflowAppAuthDatastore(ctx, appAuth, appAuth.Id)
8460-
if err != nil {
8461-
log.Printf("Failed setting appauth for with name %s", appAuth.Label)
8462-
} else {
8463-
appsAdded = append(appsAdded, outerapp.ID)
8464-
}
8465-
}
8466-
*/
8467-
84688437
log.Printf("[DEBUG] NOT adding authentication for workflow %s (%s) in org %s (%s) automatically as this should be done from within the workflow/during setup.", workflow.Name, workflow.ID, user.ActiveOrg.Name, user.ActiveOrg.Id)
84698438

84708439
action.Errors = append(action.Errors, "Requires authentication")
@@ -8494,6 +8463,8 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
84948463
}
84958464
}
84968465

8466+
workflow.Actions = newActions
8467+
84978468
auth, authOk := request.URL.Query()["set_auth"]
84988469
if authOk && len(auth) > 0 && auth[0] == "true" {
84998470
for actionIndex, action := range workflow.Actions {
@@ -8524,7 +8495,6 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
85248495
}
85258496
}
85268497

8527-
workflow.Actions = newActions
85288498
workflow.IsValid = true
85298499

85308500
// TBD: Is this too drastic? May lead to issues in the future.
@@ -8647,10 +8617,6 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
86478617
}
86488618
}
86498619

8650-
for _, action := range workflow.Actions {
8651-
log.Printf("ACTION2: %#v: %d", action.Name, len(action.Parameters))
8652-
}
8653-
86548620
err = SetWorkflow(ctx, workflow, workflow.ID)
86558621
if err != nil {
86568622
log.Printf("[ERROR] Failed saving workflow to database: %s", err)
@@ -20150,7 +20116,6 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
2015020116
newResults := []ActionResult{}
2015120117
foundresult := ActionResult{}
2015220118
for _, result := range oldExecution.Results {
20153-
log.Printf("\n\n[DEBUG] Action: %s: %s. Start: %s\n\n", result.Action.ID, result.Status, start[0])
2015420119
if result.Action.ID == start[0] {
2015520120
if result.Status == "ABORTED" {
2015620121
log.Printf("[INFO] Found aborted result: %s (%s)", result.Action.Label, result.Action.ID)

0 commit comments

Comments
 (0)