fix(datasource): 修复 zstd 响应 JSON 解析问题
- flask_api_source.py: 添加 requests.exceptions.JSONDecodeError 捕获 - flask_server.py: 启用 flask-compress gzip 压缩 - requirements.txt: 添加 flask-compress>=1.14 - strategy.py: 修复 flask_api 配置读取方式 问题原因:Traefik Ingress 使用 zstd 压缩响应, requests.response.json() 解析失败,但 json.loads(response.text) 成功
This commit is contained in:
@@ -109,7 +109,12 @@ class FlaskAPIDataSource:
|
||||
print(f"✗ API请求失败: {response.status_code} - {response.text[:100]}")
|
||||
return None
|
||||
|
||||
data = response.json()
|
||||
# 尝试解析 JSON(支持 zstd 响应)
|
||||
try:
|
||||
data = response.json()
|
||||
except (json.JSONDecodeError, requests.exceptions.JSONDecodeError):
|
||||
# 如果 response.json() 失败,手动解析
|
||||
data = json.loads(response.text)
|
||||
|
||||
# 检查错误
|
||||
if 'error' in data:
|
||||
|
||||
Reference in New Issue
Block a user