From b1066463e7f2b97efcd3aaed7f42656d0933a118 Mon Sep 17 00:00:00 2001 From: "agent.develop" Date: Thu, 17 Sep 2026 23:17:09 +0800 Subject: [PATCH] =?UTF-8?q?deliver:=20=E4=BA=A4=E4=BB=98=E6=94=B6=E5=8F=A3?= =?UTF-8?q?=EF=BC=88=E5=BC=95=E6=93=8E=E4=BB=A3=E4=B8=BA=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pbl_common/audit.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pbl_common/audit.py b/pbl_common/audit.py index cac9913..e834aeb 100644 --- a/pbl_common/audit.py +++ b/pbl_common/audit.py @@ -87,12 +87,13 @@ def build_audit_record(action, table=None, row_id=None, detail=None, ctx=None, tenant_id=None, actor_id=None, actor_type=None, trace_id=None, result='ok', created_at=None): """构造一条审计记录 dict(tenant_id 打头,不落库)。""" - tid = normalize_tenant(tenant_id if tenant_id is not None else _safe_tenant(ctx)) - if not tid: + raw_tid = tenant_id if tenant_id is not None else _safe_tenant(ctx) + if raw_tid is None or str(raw_tid).strip() == '': raise ParamInvalidError( code=PBL_E_TENANT_MISSING, message='审计写入缺少 tenant_id(审计同样强制租户打头)', detail={'action': action, 'table': table}) + tid = normalize_tenant(raw_tid) if ctx is None: try: ctx_obj = current_context(strict=False)