From 80d8e47e420bfdda080dbae0ef6562aa506665a4 Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Wed, 25 Dec 2024 18:23:31 +0800 Subject: [PATCH] fix: skip json transforming if error occurs --- api/core/plugin/manager/agent.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/core/plugin/manager/agent.py b/api/core/plugin/manager/agent.py index 0a2fb0e2d6..10db8b5581 100644 --- a/api/core/plugin/manager/agent.py +++ b/api/core/plugin/manager/agent.py @@ -48,6 +48,10 @@ class PluginAgentManager(BasePluginManager): agent_provider_id = GenericProviderID(provider) def transformer(json_response: dict[str, Any]) -> dict: + # skip if error occurs + if json_response.get("data") is None or json_response.get("data", {}).get("declaration") is None: + return json_response + for strategy in json_response.get("data", {}).get("declaration", {}).get("strategies", []): strategy["identity"]["provider"] = agent_provider_id.provider_name