From dff536ab6d49a5d5e770a86e803e1b274d2e86d2 Mon Sep 17 00:00:00 2001 From: Harry Date: Mon, 20 Oct 2025 15:07:36 +0800 Subject: [PATCH] feat(trigger): trigger plugin protocol improvements --- api/controllers/trigger/trigger.py | 3 ++- api/core/plugin/entities/request.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/api/controllers/trigger/trigger.py b/api/controllers/trigger/trigger.py index ce71d788f0..4640f0b198 100644 --- a/api/controllers/trigger/trigger.py +++ b/api/controllers/trigger/trigger.py @@ -37,7 +37,8 @@ def trigger_endpoint(endpoint_id: str): return jsonify({"error": "Endpoint not found"}), 404 return response except ValueError as e: - raise NotFound(str(e)) + logger.exception("Endpoint processing failed for {endpoint_id}: {e}") + return jsonify({"error": "Endpoint processing failed", "message": str(e)}), 500 except Exception as e: logger.exception("Webhook processing failed for {endpoint_id}") return jsonify({"error": "Internal server error", "message": str(e)}), 500 diff --git a/api/core/plugin/entities/request.py b/api/core/plugin/entities/request.py index 4b0c697570..995d52ac6e 100644 --- a/api/core/plugin/entities/request.py +++ b/api/core/plugin/entities/request.py @@ -1,4 +1,5 @@ import binascii +import json from collections.abc import Mapping from typing import Any, Literal, Optional @@ -247,6 +248,16 @@ class TriggerInvokeEventResponse(BaseModel): variables: Mapping[str, Any] = Field(default_factory=dict) cancelled: Optional[bool] = False + model_config = ConfigDict(protected_namespaces=(), arbitrary_types_allowed=True) + + @field_validator("variables", mode="before") + @classmethod + def convert_variables(cls, v): + if isinstance(v, str): + return json.loads(v) + else: + return v + class TriggerSubscriptionResponse(BaseModel): subscription: dict[str, Any]