fix(site-import): 终审两阻塞——移除诊断落盘(c0eae14 反向提交修正)+ 租户 AI 槽位接线(routes→task→make_provider 传配置快照)

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-10-21 00:00:31 +08:00
parent 3a51b24565
commit c2ccf8b1ae
4 changed files with 40 additions and 17 deletions
+11 -1
View File
@@ -20,8 +20,10 @@
"""
from fastapi import APIRouter, Depends, HTTPException, Request
from pydantic import BaseModel
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.platform.db import TenantConfigVersion
from app.platform.routes.tenant_routes import _get_tenant_or_404, _tenant_guard
from app.platform.site_import import safe_fetch, task
@@ -41,6 +43,13 @@ async def start_import(slug: str, body: StartRequest, request: Request,
engine = request.app.state.platform_engine
async with AsyncSession(engine, expire_on_commit=False) as session:
tenant = await _get_tenant_or_404(session, slug)
# 租户配置快照(终审 Important #2:AI 三级链的租户槽位——传给
# task.start → make_provider;自有 ai.* 配置的租户烧自己配额)
latest = (await session.execute(
select(TenantConfigVersion.config_json)
.where(TenantConfigVersion.tenant_id == tenant.id)
.order_by(TenantConfigVersion.version.desc())
.limit(1))).scalar_one_or_none()
if tenant.status != "active":
raise HTTPException(
status_code=403, detail=f"租户 {slug!r} 已停用,无法发起导入")
@@ -67,7 +76,8 @@ async def start_import(slug: str, body: StartRequest, request: Request,
url = body.url
try:
task_id = await task.start(slug, url, retry_task_id=retry_task_id)
task_id = await task.start(slug, url, retry_task_id=retry_task_id,
config_data=latest)
except task.ImportRateLimited as exc:
raise HTTPException(status_code=429, detail=str(exc)) from exc
except task.ConcurrentLimit as exc: