From f315a8ddcfc1475179d52495a0c221bfba0df116 Mon Sep 17 00:00:00 2001 From: Blackoutta Date: Fri, 27 Feb 2026 13:22:12 +0800 Subject: [PATCH] fix: error handling on credential validation --- .../interfaces/model/openai_compatible/llm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/dify_plugin/interfaces/model/openai_compatible/llm.py b/python/dify_plugin/interfaces/model/openai_compatible/llm.py index 47861d2a..11035659 100644 --- a/python/dify_plugin/interfaces/model/openai_compatible/llm.py +++ b/python/dify_plugin/interfaces/model/openai_compatible/llm.py @@ -171,6 +171,7 @@ def validate_credentials(self, model: str, credentials: dict) -> None: :param credentials: model credentials :return: """ + response = None try: headers = {"Content-Type": "application/json"} @@ -255,9 +256,15 @@ def validate_credentials(self, model: str, credentials: dict) -> None: ) except CredentialsValidateFailedError: raise + except requests.RequestException as ex: + raise CredentialsValidateFailedError( + f"Credentials validation request failed: {ex!s}" + ) from ex except Exception as ex: + response_body = response.text if response is not None else "" raise CredentialsValidateFailedError( - f"An error occurred during credentials validation: {ex!s}, response body {response.text}" + f"An error occurred during credentials validation: {ex!s}, " + f"response body {response_body}" ) from ex def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity: