fix: formular trigger

This commit is contained in:
Ida 2026-05-14 11:14:55 +02:00
parent 64591fda3f
commit f115bd9aa2
2 changed files with 39 additions and 0 deletions

View file

@ -21,6 +21,7 @@ class TriggerExecutor:
context: Dict[str, Any],
) -> Any:
node_id = node.get("id", "")
node_type = str(node.get("type") or "")
base = context.get("runEnvelope")
if not isinstance(base, dict):
out = normalize_run_envelope(None, user_id=context.get("userId"))
@ -31,4 +32,11 @@ class TriggerExecutor:
node_id,
(out.get("trigger") or {}).get("type"),
)
# Form start: port schema is FormPayload — downstream refs use payload.<field>.
# Do not emit the full run envelope on this port.
if node_type == "trigger.form":
payload = out.get("payload")
if not isinstance(payload, dict):
payload = {}
return {"payload": payload, "_success": True}
return out

View file

@ -0,0 +1,31 @@
# Copyright (c) 2025 Patrick Motsch
"""TriggerExecutor: form start output must match FormPayload (payload.* refs)."""
import pytest
from modules.workflows.automation2.executors.triggerExecutor import TriggerExecutor
from modules.workflows.automation2.runEnvelope import default_run_envelope
@pytest.mark.asyncio
async def test_trigger_form_returns_payload_only():
ex = TriggerExecutor()
node = {
"id": "f1",
"type": "trigger.form",
"parameters": {"formFields": [{"name": "q", "type": "str", "label": "Q"}]},
}
env = default_run_envelope("form", entry_point_id="f1", payload={"q": "hello"})
out = await ex.execute(node, {"runEnvelope": env, "userId": "u1"})
assert out == {"payload": {"q": "hello"}, "_success": True}
@pytest.mark.asyncio
async def test_trigger_manual_still_returns_full_envelope():
ex = TriggerExecutor()
node = {"id": "m1", "type": "trigger.manual", "parameters": {}}
env = default_run_envelope("manual", payload={"x": 1})
out = await ex.execute(node, {"runEnvelope": env, "userId": "u1"})
assert isinstance(out, dict)
assert out.get("trigger", {}).get("type") == "manual"
assert out.get("payload") == {"x": 1}