fix: 修复监控链路 api_key 未解码致 401、瞬时 401 误禁、前端表单多处问题 - monitor: 调度链路对 base64 存储的 api_key 解码(此前直接发送编码串导致所有账号 401) - fetcher: 401/403 先按重试次数确认再判定禁用,避免瞬时 401 误杀;POST 自动补 Content-Type: application/json - ui: val/err 兼容 # 前缀(保存无反应的根因);平台编辑回填 headers 反转义;监控页补添加账号入口 - test: 新增 monitor 解码回归测试,共 51 个用例
This commit is contained in:
@@ -68,6 +68,8 @@ def _build_request(platform: dict, api_key: str) -> tuple[str, dict, str | None]
|
||||
body = None
|
||||
if platform["method"] == "POST" and platform.get("body"):
|
||||
body = render_template(platform["body"], api_key)
|
||||
if not any(k.lower() == "content-type" for k in headers):
|
||||
headers["Content-Type"] = "application/json"
|
||||
return url, headers, body
|
||||
|
||||
|
||||
@@ -95,6 +97,11 @@ def fetch_balance(platform: dict, api_key: str, retry_count: int, timeout: int)
|
||||
time.sleep(2)
|
||||
continue
|
||||
if resp.status_code in (401, 403):
|
||||
# 认证失败可能是瞬时的(key 刚生效/风控),先按重试次数再确认,仍失败才判定
|
||||
if attempt < attempts - 1:
|
||||
logger.warning("认证失败(%s/%s) %s status=%s,重试确认", attempt + 1, attempts, url, resp.status_code)
|
||||
time.sleep(1)
|
||||
continue
|
||||
return FetchResult(ok=False, auth_error=True, status_code=resp.status_code,
|
||||
error=f"HTTP {resp.status_code}(认证失败)")
|
||||
if resp.status_code >= 500:
|
||||
|
||||
Reference in New Issue
Block a user