@@ -26,7 +26,6 @@ import (
2626 "github.com/frikky/kin-openapi/openapi3"
2727)
2828
29-
3029// Runs attempts up to X times
3130var maxRerunAttempts = 7
3231var standalone = false
@@ -1245,6 +1244,8 @@ func RunActionWrapper(ctx context.Context, user shuffle.User, value shuffle.Cate
12451244 }
12461245 }
12471246
1247+ selectedAction = GetTranslatedHttpAction (selectedApp , selectedAction )
1248+
12481249 if len (selectedAction .Name ) == 0 && value .Label != "discover_app" {
12491250 log .Printf ("[WARNING] Couldn't find the label '%s' in app '%s'." , value .Label , selectedApp .Name )
12501251
@@ -1998,9 +1999,9 @@ func RunActionWrapper(ctx context.Context, user shuffle.User, value shuffle.Cate
19981999 missingFields = shuffle .RemoveFromArray (missingFields , key )
19992000 }
20002001
2001- if debug {
2002- log .Printf ("[DEBUG] OLD BODY: \n \n %s\n \n NEW BODY: \n \n %s" , param .Value , string (marshalledMap ))
2003- }
2002+ // if debug {
2003+ // log.Printf("[DEBUG] OLD BODY: \n\n%s\n\nNEW BODY: \n\n%s", param.Value, string(marshalledMap))
2004+ // }
20042005
20052006
20062007 } else {
@@ -2138,11 +2139,6 @@ func RunActionWrapper(ctx context.Context, user shuffle.User, value shuffle.Cate
21382139 }
21392140
21402141 // Translates from Shuffle Action -> Pure HTTP if possible
2141- // This makes for better autocorrects
2142- secondAction = GetTranslatedHttpAction (selectedApp , secondAction )
2143- log .Printf ("Quitting. Action: %s, App: %s" , secondAction .Name , secondAction .AppID )
2144-
2145- //os.Exit(3)
21462142
21472143 // Runs individual apps, one at a time
21482144 if value .SkipWorkflow {
@@ -2250,10 +2246,9 @@ func RunActionWrapper(ctx context.Context, user shuffle.User, value shuffle.Cate
22502246 missingBodyParams := validatePreparedActionHasFields (preparedAction , value .Fields , i )
22512247
22522248 // FIXME: How to deal with random fields here?
2253- if debug {
2249+ if debug && len ( missingBodyParams ) > 0 {
22542250 log .Printf ("\n \n \n MISSING PARAMS: %#v\n \n \n " , missingBodyParams )
22552251 }
2256- //os.Exit(3)
22572252
22582253 if len (missingBodyParams ) > 0 {
22592254
@@ -2570,6 +2565,7 @@ func RunActionWrapper(ctx context.Context, user shuffle.User, value shuffle.Cate
25702565 // additionalInfo: recursively filled in from this function
25712566 // inputQuery: the input we got initially
25722567 outputString , outputAction , err , additionalInfo := shuffle .FindNextApiStep (
2568+ value .Fields ,
25732569 secondAction ,
25742570 apprunBody ,
25752571 additionalInfo ,
@@ -2769,7 +2765,7 @@ func RunActionWrapper(ctx context.Context, user shuffle.User, value shuffle.Cate
27692765 }
27702766
27712767 if debug {
2772- log .Printf ("\n \n \n [DEBUG ] Done in autocorrect loop\n \n \n " )
2768+ log .Printf ("[ERROR ] Done in autocorrect loop after %d iterations. This means Singul failure for action %s." , maxRerunAttempts , secondAction . Name )
27732769 }
27742770 }
27752771
@@ -3010,7 +3006,8 @@ func RunActionWrapper(ctx context.Context, user shuffle.User, value shuffle.Cate
30103006
30113007// Translates and action IF custom_action is available
30123008// Uses OpenAPI spec to do so
3013- func GetTranslatedHttpAction (app shuffle.WorkflowApp , action shuffle.Action ) shuffle.Action {
3009+ //func GetTranslatedHttpAction(app shuffle.WorkflowApp, action shuffle.Action) shuffle.Action {
3010+ func GetTranslatedHttpAction (app shuffle.WorkflowApp , action shuffle.WorkflowAppAction ) shuffle.WorkflowAppAction {
30143011 if app .ID == "" || app .Name == "" {
30153012 return action
30163013 }
@@ -3021,7 +3018,7 @@ func GetTranslatedHttpAction(app shuffle.WorkflowApp, action shuffle.Action) shu
30213018 return action
30223019 }
30233020
3024- if action .Name == "custom_action" || action .Name == "api" {
3021+ if action .Name == "custom_action" || action .Name == "api" || action . Name == "" {
30253022 return action
30263023 }
30273024
@@ -3046,6 +3043,20 @@ func GetTranslatedHttpAction(app shuffle.WorkflowApp, action shuffle.Action) shu
30463043
30473044 // Maybe just force in missing fields first?
30483045 // That makes it so that e.g. failover can use custom_action while by default we don't... hmm
3046+ allowedApiParameters := []string {"method" , "url" , "path" , "queries" , "headers" , "body" }
3047+ newParams := []shuffle.WorkflowAppActionParameter {}
3048+ for _ , param := range action .Parameters {
3049+ if param .Configuration == false && ! shuffle .ArrayContains (allowedApiParameters , strings .ToLower (param .Name )) {
3050+ continue
3051+ }
3052+
3053+ newParams = append (newParams , param )
3054+ }
3055+
3056+ if len (newParams ) != len (action .Parameters ) && len (newParams ) > 0 {
3057+ action .Parameters = newParams
3058+ }
3059+
30493060 for _ , customActionParam := range app .Actions [customActionIndex ].Parameters {
30503061 found := false
30513062 for _ , param := range action .Parameters {
@@ -3055,6 +3066,7 @@ func GetTranslatedHttpAction(app shuffle.WorkflowApp, action shuffle.Action) shu
30553066 }
30563067 }
30573068
3069+
30583070 /*
30593071 // Definitions
30603072 newDesc := fmt.Sprintf("%s\n\n%s", path.Get.Description, baseUrl)
@@ -3149,14 +3161,15 @@ func GetTranslatedHttpAction(app shuffle.WorkflowApp, action shuffle.Action) shu
31493161 }
31503162
31513163 if debug {
3152- log .Printf ("[DEBUG] Appending '%s' with value %#v" , customActionParam .Name , customActionParam .Value )
3164+ log .Printf ("[DEBUG] Appending '%s' with value %#v (custom_action) " , customActionParam .Name , customActionParam .Value )
31533165 }
31543166
31553167 action .Parameters = append (action .Parameters , customActionParam )
31563168
31573169 }
31583170 }
31593171
3172+
31603173 action .Name = "custom_action"
31613174 return action
31623175}
@@ -3624,7 +3637,7 @@ func SetupRequirements(requirementsPath string) error {
36243637 return err
36253638 }
36263639
3627- // Copy output to buffers
3640+ // Copy output to buffers -> prints
36283641 go io .Copy (& stdoutBuf , stdoutPipe )
36293642 go io .Copy (& stderrBuf , stderrPipe )
36303643
@@ -3727,15 +3740,14 @@ func handleStandaloneExecution(workflow shuffle.Workflow) ([]byte, error) {
37273740 if len (os .Getenv ("SHUFFLE_APP_SDK_TIMEOUT" )) == 0 {
37283741 appTimeout := "30"
37293742 os .Setenv ("SHUFFLE_APP_SDK_TIMEOUT" , appTimeout )
3730- log .Printf ("Set App timeout to %s seconds" , appTimeout )
37313743 }
37323744
37333745 returnBody := []byte (fmt .Sprintf (`{"success": false, "reason": "No action taken"}` ))
37343746 if len (workflow .Actions ) != 1 {
3735- log .Printf ("[DEBUG] EXECUTION ACTIONS: %d. CHoosing the LAST node." , len (workflow .Actions ))
3736- for _ , action := range workflow .Actions {
3737- log .Printf ("[DEBUG] ACTION - Name: %s, Label: %s, AppID: %s" , action .Name , action .Label , action .AppID )
3738- }
3747+ // log.Printf("[DEBUG] EXECUTION ACTIONS: %d. CHoosing the LAST node.", len(workflow.Actions))
3748+ // for _, action := range workflow.Actions {
3749+ // log.Printf("[DEBUG] ACTION - Name: %s, Label: %s, AppID: %s", action.Name, action.Label, action.AppID)
3750+ // }
37393751
37403752 workflow .Actions = []shuffle.Action {
37413753 workflow .Actions [len (workflow .Actions )- 1 ],
@@ -3799,15 +3811,10 @@ func handleStandaloneExecution(workflow shuffle.Workflow) ([]byte, error) {
37993811
38003812 // Run the command
38013813 if debug {
3802- log .Printf ("Exec start " )
3814+ log .Printf ("\n \n \n [DEBUG] START APP EXEC (for timing) \n \n \n " )
38033815 }
3804-
38053816 cmd := exec .Command (pythonPath , pythonCommandSplit ... )
38063817
3807- if debug {
3808- log .Printf ("Exec done" )
3809- }
3810-
38113818 //cmd.Dir = appscriptFolder
38123819 stdoutPipe , err := cmd .StdoutPipe ()
38133820 if err != nil {
@@ -3860,7 +3867,7 @@ func handleStandaloneExecution(workflow shuffle.Workflow) ([]byte, error) {
38603867 }
38613868
38623869 if debug {
3863- log .Printf ("STDERR1: %s" , stderrStr )
3870+ log .Printf ("\n \n \n [DEBUG] DONE APP EXEC (for timing) \n \n \n " )
38643871 }
38653872
38663873 record := false
0 commit comments