Skip to content

Commit 2cbb7d5

Browse files
committed
Made branch checks on startnode possible
1 parent 240f43d commit 2cbb7d5

2 files changed

Lines changed: 66 additions & 12 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='shuffle_sdk',
5-
version='0.0.37',
5+
version='0.0.38',
66
description='The SDK used for Shuffle',
77
py_modules=["shuffle_sdk"],
88
license='MIT',

shuffle_sdk/shuffle_sdk.py

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,6 +2059,7 @@ def execute_action(self, action):
20592059
"name": args.action,
20602060
"parameters": [],
20612061
"standalone": True,
2062+
"id": "standalone",
20622063

20632064
"app_name": ""
20642065
}
@@ -2085,8 +2086,6 @@ def execute_action(self, action):
20852086
if newkey.startswith("'") and newkey.endswith("'"):
20862087
newkey = newkey[1:-1]
20872088

2088-
print("KEY: %s" % newkey)
2089-
20902089
if newkey == "shuffle_authorization":
20912090
self.authorization = keysplit[1]
20922091
continue
@@ -3509,21 +3508,31 @@ def check_branch_conditions(action, fullexecution, self):
35093508
# relevantbranches = workflow.branches where destination = action
35103509
try:
35113510
if fullexecution["workflow"]["branches"] == None or len(fullexecution["workflow"]["branches"]) == 0:
3511+
if os.getenv("DEBUG", "").lower() == "true":
3512+
self.logger.info("[DEBUG] No branches found in workflow, skipping branch condition checks.")
3513+
35123514
return True, ""
35133515
except KeyError:
35143516
return True, ""
35153517

35163518
# Startnode should always run - no need to check incoming
35173519
# Removed November 2023 due to people wanting startnode to also check
3518-
# This is to make it possible ot
3519-
try:
3520-
if action["id"] == fullexecution["start"]:
3521-
return True, ""
3520+
# Re-Removed April 2026 to optimise e.g. for scheduler and single action sub-runs
3521+
#try:
3522+
# pass
3523+
# if action["id"] == fullexecution["start"]:
3524+
# if os.getenv("DEBUG", "").lower() == "true":
3525+
# self.logger.info("[DEBUG] Action is start node, skipping branch condition checks.")
3526+
3527+
# return True, ""
35223528

3523-
except Exception as error:
3524-
self.logger.info(f"[WARNING] Failed checking startnode: {error}")
3525-
#return True, ""
3526-
#return True, ""
3529+
#except Exception as error:
3530+
# self.logger.info(f"[WARNING] Failed checking startnode: {error}")
3531+
# #return True, ""
3532+
# #return True, ""
3533+
3534+
if os.getenv("DEBUG", "").lower() == "true":
3535+
self.logger.info("[DEBUG] Checking branch conditions for action %s" % action["id"])
35273536

35283537
available_checks = [
35293538
"=",
@@ -3649,9 +3658,43 @@ def check_branch_conditions(action, fullexecution, self):
36493658
#
36503659
#
36513660
if self.standalone:
3661+
fullexecution["start"] = "standalone"
3662+
fullexecution["workflow"]["branches"] = [{
3663+
"source_id": "huh",
3664+
"destination_id": "standalone",
3665+
"_id": "b0170bd1-11bc-4bc0-ab2f-c09b2d55f47f",
3666+
"id": "b0170bd1-11bc-4bc0-ab2f-c09b2d55f47f",
3667+
"conditions": [
3668+
{
3669+
"source": {
3670+
"name": "source",
3671+
"value": "true",
3672+
"variant": "STATIC_VALUE",
3673+
"action_field": "",
3674+
"id": "458ff31c-4c27-4309-8891-b8b9e7bb624c"
3675+
},
3676+
"condition": {
3677+
"name": "condition",
3678+
"value": "equals",
3679+
"id": "458ff31c-4c27-4309-8891-b8b9e7bb624c"
3680+
},
3681+
"destination": {
3682+
"name": "destination",
3683+
"value": "true",
3684+
"variant": "STATIC_VALUE",
3685+
"action_field": "",
3686+
"id": "458ff31c-4c27-4309-8891-b8b9e7bb624c"
3687+
}
3688+
}
3689+
],
3690+
"label": "",
3691+
"is_valid": True,
3692+
}]
3693+
3694+
# Just a test even we've been using to have $exec ref
36523695
fullexecution["execution_argument"] = '{"activity":[{"attachments":[],"content":"@AIAgent what about 1.2.3.4?","details":"From: Diego Ruiz\nTo: phishing@example.com\nSubject: FW: [SUSPICIOUS] IT Support — Action required: reset your MFA\nDate: Thu, 23 Apr 2026 12:49:48 GMT\n\nHi security team,\n\nForwarding the email below — it looks like a phishing attempt impersonating IT support. I did not click the link.\n\nI also noticed my colleague Sarah Chen (Finance Analyst) received the exact same message. I have not been able to confirm yet whether she clicked it. Could you take a look?\n\nThanks,\nDiego Ruiz\nSenior Accountant, Finance\n\n---------- Forwarded message ----------\nFrom: IT Support\nTo: diego.ruiz@example.com\nSubject: [Action required] Reset your MFA within 24 hours\nDate: Thu, 23 Apr 2026 12:35:48 GMT\n\nDear user,\n\nOur records indicate that your multi-factor authentication enrollment is out of date. To avoid losing access to your account, please reset your MFA within the next 24 hours by visiting the secure portal below:\n\nhttps://112.94.99.84/mfa-reset?u=schen\n\nIf you do not complete this step, your account will be temporarily suspended.\n\nThank you,\nIT Support Team"}'
36533696

3654-
# THE START IS ACTUALLY RIGHT HERE :O
3697+
# THE START IS ACTUALLY RIGHT HERE
36553698
# Checks whether conditions are met, otherwise set
36563699
branchcheck, tmpresult = check_branch_conditions(action, fullexecution, self)
36573700
if isinstance(tmpresult, object) or isinstance(tmpresult, list) or isinstance(tmpresult, dict):
@@ -3665,6 +3708,17 @@ def check_branch_conditions(action, fullexecution, self):
36653708

36663709
# IF branches fail: Exit!
36673710
if not branchcheck:
3711+
if self.standalone or self.authorization == "standalone":
3712+
valid_json = False
3713+
try:
3714+
json_object = json.loads(tmpresult)
3715+
valid_json = True
3716+
except Exception as e:
3717+
pass
3718+
3719+
print("\n\n===== Successful result From the Function (JSON: %s) =====\n\n%s" % (valid_json, tmpresult))
3720+
exit()
3721+
36683722
self.action_result["result"] = tmpresult
36693723
self.action_result["status"] = "SKIPPED"
36703724
self.action_result["completed_at"] = int(time.time_ns())

0 commit comments

Comments
 (0)