diff --git a/python/dify_plugin/interfaces/trigger/__init__.py b/python/dify_plugin/interfaces/trigger/__init__.py index 197d30ad..800910c8 100644 --- a/python/dify_plugin/interfaces/trigger/__init__.py +++ b/python/dify_plugin/interfaces/trigger/__init__.py @@ -426,6 +426,11 @@ def delete_subscription( If this method raises an exception, Dify will still remove the subscription but display a warning message to the user. + If the subscription no longer exists on the external service (e.g., already + deleted or expired), this method should return `success=True`. This ensures + idempotent behavior, as the desired state (the subscription being absent) + is already met. + Examples: Successful unsubscription: >>> subscription = Subscription( diff --git a/python/examples/github_trigger/provider/github.py b/python/examples/github_trigger/provider/github.py index ed28550b..d76aaa0f 100644 --- a/python/examples/github_trigger/provider/github.py +++ b/python/examples/github_trigger/provider/github.py @@ -338,10 +338,8 @@ def _delete_subscription( ) if response.status_code == 404: - raise UnsubscribeError( - message=f"Webhook {external_id} not found in repository {repository}", - error_code="WEBHOOK_NOT_FOUND", - external_response=response.json(), + return UnsubscribeResult( + success=True, message=f"Webhook {external_id} not found in repository {repository}" ) raise UnsubscribeError(