Skip to content

Commit 1eb3aee

Browse files
committed
Minor fixes to cookie due to cross-origin access
1 parent 77038f1 commit 1eb3aee

File tree

2 files changed

+60
-5
lines changed

2 files changed

+60
-5
lines changed

ai.go

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,7 @@ func AutofixAppLabels(app WorkflowApp, label string, keys []string) (WorkflowApp
16741674

16751675
var guessedAction WorkflowAppAction
16761676
type ActionStruct struct {
1677+
Success bool `json:"success"`
16771678
Action string `json:"action"`
16781679
}
16791680

@@ -1708,7 +1709,12 @@ func AutofixAppLabels(app WorkflowApp, label string, keys []string) (WorkflowApp
17081709
//userMessage := "The available actions are as follows:\n"
17091710

17101711
if cacheGeterr != nil {
1711-
systemMessage := `Your goal is to find the most correct action for a specific label from the actions. You have to pick the most likely action. Synonyms are accepted, and you should be very critical to not make mistakes. A synonym example can be something like: case = alert = ticket = issue = task, or message = chat = communication. Be extra careful of not confusing LIST and GET operations, based on the user query, respond with the most likely action name. If it exists, return {"success": true, "action": "<action>"} where <action> is replaced with the action found. If it does not exist, Last case scenario is return {"success": false, "action": ""}. Output as JSON."`
1712+
systemMessage := `Your goal is to find the most correct action for a specific label from the actions. You have to pick the most likely action. Synonyms are accepted, and you should be very critical to not make mistakes. A synonym example can be something like: case = alert = ticket = issue = task, or message = chat = communication. Be extra careful of not confusing LIST and GET operations, based on the user query, respond with the most likely action name. If it exists, return {"success": true, "action": "<action>"} where <action> is replaced with the action found. If it does not exist, Last case scenario is return {"success": false, "action": ""}. Output as JSON with JUST the action name."`
1713+
1714+
if label == "app_validation" || label == "test" || label == "test_api" {
1715+
systemMessage = fmt.Sprintf(`Your goal is to find the most correct action for TESTING an API. You have to pick the most likely action. Synonyms are accepted. A synonym example can be something like: case = alert = ticket = issue = task, or message = chat = communication. E.g. for ITSM it should be to list tickets. For email, to list emails. For EDR, to list alerts etc. Find a simple API. The current app is '%s'. Our goal is to get a 200 OK or similar. If it exists, return {"success": true, "action": "<action>"} where <action> is replaced with the action found. If it does not exist, Last case scenario is return {"success": false, "action": ""}. Output as JSON, with JUST the action name.`, app.Name)
1716+
}
1717+
17121718
userMessage := fmt.Sprintf("Out of the following actions, which action matches '%s'?\n", label)
17131719

17141720
//changedNames := map[string]string{}
@@ -1744,6 +1750,12 @@ func AutofixAppLabels(app WorkflowApp, label string, keys []string) (WorkflowApp
17441750
method = "DELETE"
17451751
}
17461752

1753+
if label == "app_validation" || label == "test" || label == "test_api" {
1754+
if method != "GET" {
1755+
continue
1756+
}
1757+
}
1758+
17471759
// We need to parse out the url from description to help
17481760
parsedDescriptionUrlPath := ""
17491761
for _, line := range strings.Split(action.Description, "\n") {
@@ -1787,7 +1799,7 @@ func AutofixAppLabels(app WorkflowApp, label string, keys []string) (WorkflowApp
17871799
parsedEnding = ""
17881800
}
17891801

1790-
userMessage += fmt.Sprintf("%s %s\n", action.Name, parsedEnding)
1802+
userMessage += fmt.Sprintf("- %s %s\n", action.Name, parsedEnding)
17911803
}
17921804

17931805
if len(keys) > 0 {
@@ -1803,7 +1815,24 @@ func AutofixAppLabels(app WorkflowApp, label string, keys []string) (WorkflowApp
18031815

18041816
}
18051817

1806-
output, err := RunAiQuery(systemMessage, userMessage)
1818+
chatCompletion := openai.ChatCompletionRequest{
1819+
Model: model,
1820+
Messages: []openai.ChatCompletionMessage{
1821+
openai.ChatCompletionMessage{
1822+
Role: openai.ChatMessageRoleSystem,
1823+
Content: systemMessage,
1824+
},
1825+
openai.ChatCompletionMessage{
1826+
Role: openai.ChatMessageRoleUser,
1827+
Content: userMessage,
1828+
},
1829+
},
1830+
MaxTokens: maxTokens,
1831+
Temperature: 0,
1832+
ReasoningEffort: "low",
1833+
}
1834+
1835+
output, err := RunAiQuery(systemMessage, userMessage, chatCompletion)
18071836
if err != nil {
18081837
log.Printf("[ERROR] Failed to run AI query in AutofixAppLabels for app %s (%s): %s", app.Name, app.ID, err)
18091838
return app, WorkflowAppAction{}
@@ -1819,6 +1848,22 @@ func AutofixAppLabels(app WorkflowApp, label string, keys []string) (WorkflowApp
18191848
log.Printf("[ERROR] FAILED action mapping parsed output: %s", output)
18201849
}
18211850

1851+
// Strip anything after the first space.
1852+
if strings.Contains(actionStruct.Action, "(") {
1853+
// Split and only keep everything based on first space
1854+
splitAction := strings.Split(actionStruct.Action, "(")
1855+
newAction := actionStruct.Action
1856+
if len(splitAction) > 0 {
1857+
newAction = strings.TrimSpace(splitAction[0])
1858+
}
1859+
1860+
if debug {
1861+
log.Printf("[DEBUG] Changing action from '%s' to '%s' based on parsing", actionStruct.Action, newAction)
1862+
}
1863+
1864+
actionStruct.Action = newAction
1865+
}
1866+
18221867
}
18231868

18241869
if len(actionStruct.Action) == 0 && cacheGeterr == nil {

shared.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ func HandleCors(resp http.ResponseWriter, request *http.Request) bool {
123123

124124
// For a new test project
125125
"https://cases.shuffler.io",
126+
"https://security.shuffler.io",
126127
"https://83c56bc8-506d-4dc5-a245-6b57e03ff019.lovableproject.com",
127128
"https://id-preview--83c56bc8-506d-4dc5-a245-6b57e03ff019.lovable.app",
128129
"https://preview--shuffle-cases.lovable.app",
@@ -249,7 +250,8 @@ func ConstructSessionCookie(value string, expires time.Time) *http.Cookie {
249250
if project.Environment == "cloud" {
250251
c.Domain = ".shuffler.io"
251252
c.Secure = true
252-
c.SameSite = http.SameSiteLaxMode
253+
//c.SameSite = http.SameSiteLaxMode
254+
c.SameSite = http.SameSiteNoneMode
253255
}
254256

255257
return &c
@@ -32148,6 +32150,12 @@ func checkExecutionStatus(ctx context.Context, exec *WorkflowExecution) *Workflo
3214832150
handledAuth := []string{}
3214932151
timenow := time.Now().Unix() * 1000
3215032152
runtimeLocationName := ""
32153+
for _, action := range exec.Workflow.Actions {
32154+
if len(action.Environment) > 0 {
32155+
runtimeLocationName = action.Environment
32156+
break
32157+
}
32158+
}
3215132159

3215232160
//log.Printf("\n\n[DEBUG][%s] STARTING VALIDATION WITH %d results and %d actions\n\n", exec.ExecutionId, len(exec.Results), len(workflow.Actions))
3215332161
for _, result := range exec.Results {
@@ -32156,7 +32164,9 @@ func checkExecutionStatus(ctx context.Context, exec *WorkflowExecution) *Workflo
3215632164
continue
3215732165
}
3215832166

32159-
runtimeLocationName = result.Action.Environment
32167+
if len(runtimeLocationName) == 0 && len(result.Action.Environment) > 0 {
32168+
runtimeLocationName = result.Action.Environment
32169+
}
3216032170

3216132171
found := false
3216232172
foundAction := Action{}

0 commit comments

Comments
 (0)