Skip to content

Commit 60e01b6

Browse files
committed
Merge branch 'main' of github.com:Shuffle/Shuffle-shared
2 parents e57c568 + 1adb68c commit 60e01b6

File tree

3 files changed

+69
-43
lines changed

3 files changed

+69
-43
lines changed

codegen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3643,7 +3643,7 @@ func HandlePut(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wor
36433643
}
36443644

36453645
func GetAppRequirements() string {
3646-
return "requests==2.32.3\nurllib3==2.3.0\nliquidpy==0.8.2\nMarkupSafe==3.0.2\nflask[async]==3.1.0\npython-dateutil==2.9.0.post0\nPyJWT==2.10.1\n"
3646+
return "requests==2.32.3\nurllib3==2.3.0\nliquidpy==0.8.2\nMarkupSafe==3.0.2\nflask[async]==3.1.0\npython-dateutil==2.9.0.post0\nPyJWT==2.10.1\nshufflepy==0.0.7\nshuffle-sdk==0.0.8"
36473647
}
36483648

36493649
// Removes JSON values from the input

db-connector.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,8 @@ func Fixexecution(ctx context.Context, workflowExecution WorkflowExecution) (Wor
19281928
}
19291929

19301930
if !skipFinished {
1931-
log.Printf("[DEBUG][%s] Setting execution to finished because all results are in and it was still in EXECUTING mode. Should set subflow parent result as well (not implemented) - just returning for now for parent function to handle.", workflowExecution.ExecutionId)
1931+
// FIXME: Is this subflow result (not implemented) valid? I think it should have been added? Hmm.
1932+
//log.Printf("[DEBUG][%s] Setting execution to finished because all results are in and it was still in EXECUTING mode. Should set subflow parent result as well (not implemented) - just returning for now for parent function to handle.", workflowExecution.ExecutionId)
19321933
finalWorkflowExecution.Status = "FINISHED"
19331934
dbsave = true
19341935
if finalWorkflowExecution.CompletedAt == 0 {
@@ -3234,6 +3235,30 @@ func GetWorkflow(ctx context.Context, id string) (*Workflow, error) {
32343235
cacheData := []byte(cache.([]uint8))
32353236
err = json.Unmarshal(cacheData, &workflow)
32363237
if err == nil && workflow.ID != "" {
3238+
// Somehow this can happen. Reverting to LATEST revision
3239+
if len(workflow.Actions) > 0 && len(workflow.Triggers) == 0 {
3240+
revisions, err := ListWorkflowRevisions(ctx, workflow.ID, 2)
3241+
if err != nil {
3242+
log.Printf("[WARNING] Failed getting revisions during trigger load for workflow %s: %s", workflow.ID, err)
3243+
} else {
3244+
if len(revisions) > 0 {
3245+
for _, revision := range revisions {
3246+
if revision.ID != workflow.ID {
3247+
continue
3248+
}
3249+
3250+
if len(revision.Triggers) > 0 {
3251+
workflow.Triggers = revision.Triggers
3252+
break
3253+
}
3254+
}
3255+
3256+
log.Printf("[INFO] Reverting to revision triggers for workflow %s from 0 triggers to %d triggers", workflow.ID, len(revisions[0].Triggers))
3257+
workflow.Triggers = revisions[0].Triggers
3258+
}
3259+
}
3260+
}
3261+
32373262
return workflow, nil
32383263
}
32393264
} else {
@@ -8211,6 +8236,10 @@ func SetWorkflowRevision(ctx context.Context, workflow Workflow) error {
82118236
}
82128237

82138238
DeleteCache(ctx, fmt.Sprintf("%s_%s", nameKey, workflow.ID))
8239+
8240+
// For workflow revision backups
8241+
DeleteCache(ctx, fmt.Sprintf("%s_%s_1", nameKey, workflow.ID))
8242+
DeleteCache(ctx, fmt.Sprintf("%s_%s_2", nameKey, workflow.ID))
82148243
}
82158244

82168245
return nil

shared.go

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5040,10 +5040,16 @@ func GetGcpSchedule(ctx context.Context, id string) (*ScheduleOld, error) {
50405040
log.Printf("[ERROR] Client error: %s", err)
50415041
return schedule, err
50425042
}
5043+
50435044
location := "europe-west2"
5044-
if len(os.Getenv("SHUFFLE_GCEPROJECT")) > 0 && len(os.Getenv("SHUFFLE_GCEPROJECT_LOCATION")) > 0 {
5045+
if len(os.Getenv("SHUFFLE_GCE_LOCATION")) > 0 {
5046+
location = os.Getenv("SHUFFLE_GCE_LOCATION")
5047+
}
5048+
5049+
if len(os.Getenv("SHUFFLE_GCE_LOCATION")) == 0 && len(os.Getenv("SHUFFLE_GCEPROJECT_LOCATION")) > 0 {
50455050
location = os.Getenv("SHUFFLE_GCEPROJECT_LOCATION")
50465051
}
5052+
50475053
req := &schedulerpb.GetJobRequest{
50485054
Name: fmt.Sprintf("projects/%s/locations/%s/jobs/schedule_%s", gceProject, location, id),
50495055
}
@@ -6520,7 +6526,7 @@ func diffWorkflows(oldWorkflow Workflow, parentWorkflow Workflow, update bool) {
65206526
// i think the following messes everything up with
65216527
// authenticationIDs. Let's just remove it for now.
65226528

6523-
// In case of replication,
6529+
// In case of replication,
65246530
parentWorkflow.Actions[actionIndex].AuthenticationId = ""
65256531

65266532
idFound := false
@@ -18491,45 +18497,10 @@ func PrepareSingleAction(ctx context.Context, user User, fileId string, body []b
1849118497
return workflowExecution, err
1849218498
}
1849318499

18494-
/*
18495-
// FIXME: Is this required? I don't think so
18496-
if app.Authentication.Required && len(action.AuthenticationId) == 0 {
18497-
18498-
// Basic bypass check for valid headers just in case
18499-
authFound := false
18500-
for _, param := range action.Parameters {
18501-
if param.Name == "headers" || param.Name == "queries" || param.Name == "url" {
18502-
lowercased := strings.ToLower(param.Value)
18503-
if strings.Contains(lowercased, "auth") || strings.Contains(lowercased, "bearer") || strings.Contains(lowercased, "basic") || strings.Contains(lowercased, "api") {
18504-
authFound = true
18505-
break
18506-
}
18507-
}
18508-
}
18509-
18510-
if !authFound {
18511-
log.Printf("[WARNING] Tried to execute SINGLE %s WITHOUT auth (missing)", app.Name)
18512-
18513-
found := false
18514-
for _, param := range action.Parameters {
18515-
if param.Configuration {
18516-
found = true
18517-
break
18518-
}
18519-
}
18520-
18521-
if !found {
18522-
return workflowExecution, errors.New("You must authenticate this API first")
18523-
}
18524-
}
18525-
}
18526-
*/
18527-
18528-
// FIXME: We need to inject missing empty auth here
18500+
// FIXME: We need to inject missing empty auth here in some cases
1852918501
// This is NOT a good solution, but a good bypass
18530-
if app.Authentication.Required {
18502+
if app.Authentication.Required && len(action.AuthenticationId) == 0 {
1853118503
authFields := 0
18532-
1853318504
foundFields := []string{}
1853418505
for _, actionParam := range action.Parameters {
1853518506
if actionParam.Configuration {
@@ -18568,6 +18539,32 @@ func PrepareSingleAction(ctx context.Context, user User, fileId string, body []b
1856818539
})
1856918540
}
1857018541
}
18542+
18543+
auths, err := GetAllWorkflowAppAuth(ctx, user.ActiveOrg.Id)
18544+
if err != nil {
18545+
log.Printf("[ERROR] Failed getting auth for single action: %s", err)
18546+
} else {
18547+
//latestTimestamp := int64(0)
18548+
for _, auth := range auths {
18549+
if auth.App.ID != fileId {
18550+
continue
18551+
}
18552+
18553+
// Fallback to latest created
18554+
/*
18555+
if latestTimestamp < auth.Created {
18556+
latestTimestamp = auth.Created
18557+
action.AuthenticationId = auth.Id
18558+
}
18559+
*/
18560+
18561+
// If valid, just choose it
18562+
if auth.Validation.Valid {
18563+
action.AuthenticationId = auth.Id
18564+
break
18565+
}
18566+
}
18567+
}
1857118568
}
1857218569

1857318570
if runValidationAction {
@@ -25429,7 +25426,7 @@ func GetExternalClient(baseUrl string) *http.Client {
2542925426

2543025427
if len(os.Getenv("SHUFFLE_INTERNAL_NO_PROXY")) > 0 {
2543125428
noProxy = os.Getenv("SHUFFLE_INTERNAL_NO_PROXY")
25432-
}
25429+
}
2543325430

2543425431
if len(os.Getenv("SHUFFLE_INTERNAL_NOPROXY")) > 0 {
2543525432
noProxy = os.Getenv("SHUFFLE_INTERNAL_NOPROXY")
@@ -25438,7 +25435,7 @@ func GetExternalClient(baseUrl string) *http.Client {
2543825435

2543925436
// Manage noproxy
2544025437
if len(noProxy) > 0 {
25441-
isNoProxy := isNoProxyHost(noProxy, parsedUrl.Host)
25438+
isNoProxy := isNoProxyHost(noProxy, parsedUrl.Host)
2544225439
if isNoProxy {
2544325440
log.Printf("[INFO] Skipping proxy for %s", parsedUrl)
2544425441

0 commit comments

Comments
 (0)