From 28ecc4d1380487831485b7119b7258526a574fe5 Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Fri, 24 Jul 2026 18:49:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20fetch=5Ffund=5Fflow=5Fdaykline=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20rc=20=E6=A0=A1=E9=AA=8C=E5=92=8C=20data=20?= =?UTF-8?q?=E7=A9=BA=E5=80=BC=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 东方财富 daykline/get 接口返回 rc=100(data=null) 时无保护处理: - 增加 result 类型检查、rc 状态校验、data 空值判断 - 避免 None.get('klines') 抛 AttributeError Co-Authored-By: Claude --- backend/services/eastmoney.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/services/eastmoney.py b/backend/services/eastmoney.py index 6271215..8fdcbd4 100644 --- a/backend/services/eastmoney.py +++ b/backend/services/eastmoney.py @@ -1074,7 +1074,20 @@ async def fetch_fund_flow_daykline(code: str, days: int) -> Optional[list[dict]] continue return None result = resp.json() - klines = result.get("data", {}).get("klines", []) + if not isinstance(result, dict): + if attempt == 0: + continue + return None + if result.get("rc", -1) != 0: + if attempt == 0: + continue + return None + data = result.get("data") + if not data or not isinstance(data, dict): + if attempt == 0: + continue + return None + klines = data.get("klines", []) if not klines: if attempt == 0: continue