From 0f1db88dcb5952a3f299ca8ace37c77708045531 Mon Sep 17 00:00:00 2001 From: wangxiaolei Date: Mon, 19 Jan 2026 16:00:44 +0800 Subject: [PATCH] fix: fix dify-plugin-daemon error message (#31218) --- api/core/plugin/impl/base.py | 15 +++++++-------- .../unit_tests/core/plugin/test_plugin_runtime.py | 5 +++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/api/core/plugin/impl/base.py b/api/core/plugin/impl/base.py index 0e49824ad0..7a6a598a2f 100644 --- a/api/core/plugin/impl/base.py +++ b/api/core/plugin/impl/base.py @@ -320,18 +320,17 @@ class BasePluginClient: case PluginInvokeError.__name__: error_object = json.loads(message) invoke_error_type = error_object.get("error_type") - args = error_object.get("args") match invoke_error_type: case InvokeRateLimitError.__name__: - raise InvokeRateLimitError(description=args.get("description")) + raise InvokeRateLimitError(description=error_object.get("message")) case InvokeAuthorizationError.__name__: - raise InvokeAuthorizationError(description=args.get("description")) + raise InvokeAuthorizationError(description=error_object.get("message")) case InvokeBadRequestError.__name__: - raise InvokeBadRequestError(description=args.get("description")) + raise InvokeBadRequestError(description=error_object.get("message")) case InvokeConnectionError.__name__: - raise InvokeConnectionError(description=args.get("description")) + raise InvokeConnectionError(description=error_object.get("message")) case InvokeServerUnavailableError.__name__: - raise InvokeServerUnavailableError(description=args.get("description")) + raise InvokeServerUnavailableError(description=error_object.get("message")) case CredentialsValidateFailedError.__name__: raise CredentialsValidateFailedError(error_object.get("message")) case EndpointSetupFailedError.__name__: @@ -339,11 +338,11 @@ class BasePluginClient: case TriggerProviderCredentialValidationError.__name__: raise TriggerProviderCredentialValidationError(error_object.get("message")) case TriggerPluginInvokeError.__name__: - raise TriggerPluginInvokeError(description=error_object.get("description")) + raise TriggerPluginInvokeError(description=error_object.get("message")) case TriggerInvokeError.__name__: raise TriggerInvokeError(error_object.get("message")) case EventIgnoreError.__name__: - raise EventIgnoreError(description=error_object.get("description")) + raise EventIgnoreError(description=error_object.get("message")) case _: raise PluginInvokeError(description=message) case PluginDaemonInternalServerError.__name__: diff --git a/api/tests/unit_tests/core/plugin/test_plugin_runtime.py b/api/tests/unit_tests/core/plugin/test_plugin_runtime.py index 2a0b293a39..9e911e1fce 100644 --- a/api/tests/unit_tests/core/plugin/test_plugin_runtime.py +++ b/api/tests/unit_tests/core/plugin/test_plugin_runtime.py @@ -346,6 +346,7 @@ class TestPluginRuntimeErrorHandling: mock_response.status_code = 200 invoke_error = { "error_type": "InvokeRateLimitError", + "message": "Rate limit exceeded", "args": {"description": "Rate limit exceeded"}, } error_message = json.dumps({"error_type": "PluginInvokeError", "message": json.dumps(invoke_error)}) @@ -364,6 +365,7 @@ class TestPluginRuntimeErrorHandling: mock_response.status_code = 200 invoke_error = { "error_type": "InvokeAuthorizationError", + "message": "Invalid credentials", "args": {"description": "Invalid credentials"}, } error_message = json.dumps({"error_type": "PluginInvokeError", "message": json.dumps(invoke_error)}) @@ -382,6 +384,7 @@ class TestPluginRuntimeErrorHandling: mock_response.status_code = 200 invoke_error = { "error_type": "InvokeBadRequestError", + "message": "Invalid parameters", "args": {"description": "Invalid parameters"}, } error_message = json.dumps({"error_type": "PluginInvokeError", "message": json.dumps(invoke_error)}) @@ -400,6 +403,7 @@ class TestPluginRuntimeErrorHandling: mock_response.status_code = 200 invoke_error = { "error_type": "InvokeConnectionError", + "message": "Connection to external service failed", "args": {"description": "Connection to external service failed"}, } error_message = json.dumps({"error_type": "PluginInvokeError", "message": json.dumps(invoke_error)}) @@ -418,6 +422,7 @@ class TestPluginRuntimeErrorHandling: mock_response.status_code = 200 invoke_error = { "error_type": "InvokeServerUnavailableError", + "message": "Service temporarily unavailable", "args": {"description": "Service temporarily unavailable"}, } error_message = json.dumps({"error_type": "PluginInvokeError", "message": json.dumps(invoke_error)})