mirror of
https://github.com/langgenius/dify.git
synced 2026-08-28 20:26:50 +08:00
fix(trigger): handle exceptions in trigger subscription dispatch
- Wrapped the dispatch call in a try-except block to catch exceptions and return a 500 error response if an error occurs. - Enhanced logging of the request and error response for better traceability in the trigger subscription workflow.
This commit is contained in:
parent
42f75b6602
commit
f23e098b9a
@ -297,15 +297,20 @@ class TriggerSubscriptionBuilderService:
|
|||||||
controller: PluginTriggerProviderController = TriggerManager.get_trigger_provider(
|
controller: PluginTriggerProviderController = TriggerManager.get_trigger_provider(
|
||||||
tenant_id=subscription_builder.tenant_id, provider_id=TriggerProviderID(subscription_builder.provider_id)
|
tenant_id=subscription_builder.tenant_id, provider_id=TriggerProviderID(subscription_builder.provider_id)
|
||||||
)
|
)
|
||||||
response: TriggerDispatchResponse = controller.dispatch(
|
try:
|
||||||
user_id=subscription_builder.user_id,
|
response: TriggerDispatchResponse = controller.dispatch(
|
||||||
request=request,
|
user_id=subscription_builder.user_id,
|
||||||
subscription=subscription_builder.to_subscription(),
|
request=request,
|
||||||
credentials={},
|
subscription=subscription_builder.to_subscription(),
|
||||||
credential_type=CredentialType.UNAUTHORIZED,
|
credentials={},
|
||||||
)
|
credential_type=CredentialType.UNAUTHORIZED,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
error_response = Response(status=500, response=str(e))
|
||||||
|
cls.append_log(endpoint_id=endpoint_id, request=request, response=error_response)
|
||||||
|
return error_response
|
||||||
# append the request log
|
# append the request log
|
||||||
cls.append_log(endpoint_id, request, response.response)
|
cls.append_log(endpoint_id=endpoint_id, request=request, response=response.response)
|
||||||
return response.response
|
return response.response
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user