fix(backend): F1-5a 走查发现 2 个生产 bug
- xcx_runtime_clock.py: require_approved 是 factory,Depends 必须 ()
调用,否则 user 是 function 不是 CurrentUser → AttributeError 500
→ 沙盒在小程序所有页面失效的根因(getBusinessClock 一直降级 localFallback)
- admin_service.py:retry_trigger_job INSERT payload 字段是 jsonb,
psycopg2 读出是 dict,未 Json() wrap 直接 INSERT 触发
"can't adapt type 'dict'" → 生产环境点重试必 500
(该 bug 在 6f8f1231 即引入,F1-5a 走查时通过 SQL 复现端到端验证暴露)
走查覆盖:
- xcx_runtime_clock: 修后小程序 GET /api/xcx/runtime/clock 200,
返回完整 sandbox ctx(business_date / sandbox_instance_id)
- retry_trigger_job: SQL 复现 INSERT 包含真实 jsonb payload
({foo:bar,n:42}),修后 runtime_mode=sandbox + sandbox_instance_id
+ payload 完整保留全部 PASS
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,7 @@ router = APIRouter(prefix="/api/xcx/runtime", tags=["小程序业务时钟"])
|
||||
@router.get("/clock")
|
||||
@trace_service("获取业务时钟", "Get business clock")
|
||||
async def get_business_clock(
|
||||
user: CurrentUser = Depends(require_approved),
|
||||
user: CurrentUser = Depends(require_approved()),
|
||||
):
|
||||
"""返回当前门店的业务时钟。
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ import uuid
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
import psycopg2.extras
|
||||
|
||||
from app.ai.budget_tracker import BudgetTracker
|
||||
from app.database import get_connection
|
||||
from app.services.runtime_context import (
|
||||
@@ -390,7 +392,11 @@ class AdminAIService:
|
||||
original.get("member_id"),
|
||||
site_id,
|
||||
original.get("connector_type", "feiqiu"),
|
||||
original.get("payload"),
|
||||
# F1-5a 走查发现:psycopg2 把 jsonb 列读成 dict,
|
||||
# INSERT 时需 Json() 适配,否则 "can't adapt type 'dict'"
|
||||
psycopg2.extras.Json(original["payload"])
|
||||
if original.get("payload") is not None
|
||||
else None,
|
||||
original.get("app_chain"),
|
||||
*runtime_params,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user