mirror of https://github.com/langgenius/dify.git
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(
|
||||
tenant_id=subscription_builder.tenant_id, provider_id=TriggerProviderID(subscription_builder.provider_id)
|
||||
)
|
||||
response: TriggerDispatchResponse = controller.dispatch(
|
||||
user_id=subscription_builder.user_id,
|
||||
request=request,
|
||||
subscription=subscription_builder.to_subscription(),
|
||||
credentials={},
|
||||
credential_type=CredentialType.UNAUTHORIZED,
|
||||
)
|
||||
try:
|
||||
response: TriggerDispatchResponse = controller.dispatch(
|
||||
user_id=subscription_builder.user_id,
|
||||
request=request,
|
||||
subscription=subscription_builder.to_subscription(),
|
||||
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
|
||||
cls.append_log(endpoint_id, request, response.response)
|
||||
cls.append_log(endpoint_id=endpoint_id, request=request, response=response.response)
|
||||
return response.response
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
Loading…
Reference in New Issue