Skip to content

Commit

Permalink
Minor app load fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed May 21, 2024
1 parent 5b02c4a commit be7e713
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app_upload/stitcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ func main() {
bucketName = os.Args[5]
}

appname := "email"
appversion := "1.3.0"
appname := "shuffle-ai"
appversion := "1.0.0"
err := deployConfigToBackend(appfolder, appname, appversion)
if err != nil {
log.Printf("[WARNING] Failed uploading config: %s", err)
Expand Down
16 changes: 11 additions & 5 deletions db-connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ func GetWorkflowExecution(ctx context.Context, id string) (*WorkflowExecution, e
if err != nil {
log.Printf("[DEBUG][%s] Failed to parse in execution file value for exec argument: %s (3)", workflowExecution.ExecutionId, err)
} else {
log.Printf("[DEBUG][%s] Found a new value to parse with exec argument", workflowExecution.ExecutionId)
//log.Printf("[DEBUG][%s] Found a new value to parse with exec argument", workflowExecution.ExecutionId)
workflowExecution.ExecutionArgument = newValue
}
}
Expand Down Expand Up @@ -1721,7 +1721,7 @@ func GetWorkflowExecution(ctx context.Context, id string) (*WorkflowExecution, e

// A workaround for large bits of information for execution argument
if strings.Contains(workflowExecution.ExecutionArgument, "Result too large to handle") {
log.Printf("[DEBUG] Found prefix %s to be replaced for exec argument (3)", workflowExecution.ExecutionArgument)
//log.Printf("[DEBUG] Found prefix %s to be replaced for exec argument (3)", workflowExecution.ExecutionArgument)
baseArgument := &ActionResult{
Result: workflowExecution.ExecutionArgument,
Action: Action{ID: "execution_argument"},
Expand All @@ -1730,7 +1730,7 @@ func GetWorkflowExecution(ctx context.Context, id string) (*WorkflowExecution, e
if err != nil {
log.Printf("[DEBUG] Failed to parse in execution file value for exec argument: %s (4)", err)
} else {
log.Printf("[DEBUG] Found a new value to parse with exec argument")
//log.Printf("[DEBUG] Found a new value to parse with exec argument")
workflowExecution.ExecutionArgument = newValue
}
}
Expand Down Expand Up @@ -1865,6 +1865,10 @@ func GetApp(ctx context.Context, id string, user User, skipCache bool) (*Workflo
return workflowApp, errors.New("No ID provided to get an app")
}

if id == "integration" {
return workflowApp, errors.New("Integration is for the integration framework. Uses the Shuffle-ai app")
}

nameKey := "workflowapp"
cacheKey := fmt.Sprintf("%s_%s", nameKey, id)

Expand Down Expand Up @@ -6252,6 +6256,7 @@ func GetUserApps(ctx context.Context, userId string) ([]WorkflowApp, error) {
cursorStr := ""

log.Printf("[DEBUG] Getting user apps for %s", userId)
var err error

queries := []datastore.Query{}
q := datastore.NewQuery(indexName).Filter("contributors =", userId)
Expand Down Expand Up @@ -6286,9 +6291,10 @@ func GetUserApps(ctx context.Context, userId string) ([]WorkflowApp, error) {
}

if err != nil {
log.Printf("[ERROR] Failed fetching user apps (1): %v", err)

if !strings.Contains(fmt.Sprintf("%s", err), "cannot load field") {
log.Printf("[ERROR] Failed fetching user apps (1): %v", err)

if strings.Contains("no matching index found", fmt.Sprintf("%s", err)) {
log.Printf("[ERROR] No more apps for %s in user app load? Breaking: %s.", userId, err)
} else {
Expand All @@ -6310,7 +6316,7 @@ func GetUserApps(ctx context.Context, userId string) ([]WorkflowApp, error) {

if err != nil {
if !strings.Contains(fmt.Sprintf("%s", err), "no more items") {
log.Printf("[ERROR] Failed fetching user apps (1): %v", err)
log.Printf("[ERROR] Failed fetching user apps (3): %v", err)
}

break
Expand Down
3 changes: 3 additions & 0 deletions oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package shuffle
import (
"bytes"
"context"
"regexp"
"crypto/sha256"
"encoding/base64"
"encoding/json"
Expand Down Expand Up @@ -4113,11 +4114,13 @@ func VerifyIdToken(ctx context.Context, idToken string) (IdTokenCheck, error) {
log.Printf("[ERROR] No org specified in state (2)")
return IdTokenCheck{}, err
}

org, err := GetOrg(ctx, foundOrg)
if err != nil {
log.Printf("[WARNING] Error getting org in OpenID (2): %s", err)
return IdTokenCheck{}, err
}

// Validating the user itself
if token.Aud == org.SSOConfig.OpenIdClientId && foundChallenge == org.SSOConfig.OpenIdClientSecret {
log.Printf("[DEBUG] Correct token aud & challenge - successful login!")
Expand Down
8 changes: 6 additions & 2 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -10428,7 +10428,7 @@ func GetWorkflowAppConfig(resp http.ResponseWriter, request *http.Request) {
//log.Printf("SHARING: %s. PUBLIC: %s", app.Sharing, app.Public)
if app.Sharing || app.Public {
if openapiok && len(openapi) > 0 && strings.ToLower(openapi[0]) == "false" {
log.Printf("Should return WITHOUT openapi")
log.Printf("[DEBUG] Returning app '%s' without OpenAPI", fileId)
} else {
//log.Printf("CAN SHARE APP!")
parsedApi, err := GetOpenApiDatastore(ctx, fileId)
Expand Down Expand Up @@ -21394,14 +21394,18 @@ func RunCategoryAction(resp http.ResponseWriter, request *http.Request) {

// FIXME: Check if ALL fields for the target app can be fullfiled
// E.g. for Jira: Org_id is required.

/*
if foundFields != len(baseFields) {
log.Printf("[WARNING] Not all required fields were found in category action. Want: %#v, have: %#v", baseFields, value.Fields)

resp.WriteHeader(400)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Not all required fields are set", "label": "%s", "missing_fields": "%s"}`, value.Label, strings.Join(missingFields, ","))))
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Not all required fields are set. This can be autocompleted from fields you fille in", "label": "%s", "missing_fields": "%s"}`, value.Label, strings.Join(missingFields, ","))))
return

}
*/
_ = baseFields

/*

Expand Down

0 comments on commit be7e713

Please sign in to comment.