mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 11:56:55 +08:00
feat(trigger): trigger plugin protocol improvements
This commit is contained in:
parent
a152ce45d3
commit
dff536ab6d
@ -37,7 +37,8 @@ def trigger_endpoint(endpoint_id: str):
|
|||||||
return jsonify({"error": "Endpoint not found"}), 404
|
return jsonify({"error": "Endpoint not found"}), 404
|
||||||
return response
|
return response
|
||||||
except ValueError as e:
|
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:
|
except Exception as e:
|
||||||
logger.exception("Webhook processing failed for {endpoint_id}")
|
logger.exception("Webhook processing failed for {endpoint_id}")
|
||||||
return jsonify({"error": "Internal server error", "message": str(e)}), 500
|
return jsonify({"error": "Internal server error", "message": str(e)}), 500
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import binascii
|
import binascii
|
||||||
|
import json
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from typing import Any, Literal, Optional
|
from typing import Any, Literal, Optional
|
||||||
|
|
||||||
@ -247,6 +248,16 @@ class TriggerInvokeEventResponse(BaseModel):
|
|||||||
variables: Mapping[str, Any] = Field(default_factory=dict)
|
variables: Mapping[str, Any] = Field(default_factory=dict)
|
||||||
cancelled: Optional[bool] = False
|
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):
|
class TriggerSubscriptionResponse(BaseModel):
|
||||||
subscription: dict[str, Any]
|
subscription: dict[str, Any]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user