fix: improve error message with actual typeId/groupId mismatch details for debugging
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from datetime import date as date_type, datetime
|
from datetime import date as date_type, datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
@@ -1576,20 +1579,25 @@ class DocumentServiceImpl(IDocumentService):
|
|||||||
await Session.execute(
|
await Session.execute(
|
||||||
text(
|
text(
|
||||||
"""
|
"""
|
||||||
SELECT id
|
SELECT id, document_type_id, name
|
||||||
FROM leaudit_evaluation_point_groups
|
FROM leaudit_evaluation_point_groups
|
||||||
WHERE id = :group_id
|
WHERE id = :group_id
|
||||||
AND document_type_id = :doc_type_id
|
|
||||||
AND deleted_at IS NULL
|
AND deleted_at IS NULL
|
||||||
AND COALESCE(pid, 0) <> 0
|
AND COALESCE(pid, 0) <> 0
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
"""
|
"""
|
||||||
),
|
),
|
||||||
{"group_id": GroupId, "doc_type_id": TypeId},
|
{"group_id": GroupId},
|
||||||
)
|
)
|
||||||
).mappings().first()
|
).mappings().first()
|
||||||
if not row:
|
if not row:
|
||||||
raise LeauditException(StatusCodeEnum.HTTP_400_BAD_REQUEST, "当前子类型不属于所选文档类型,无法上传")
|
raise LeauditException(StatusCodeEnum.HTTP_400_BAD_REQUEST, f"子类型 (id={GroupId}) 不存在或不是有效的二级分组,无法上传")
|
||||||
|
if int(row["document_type_id"] or 0) != TypeId:
|
||||||
|
logger.warning(
|
||||||
|
"_resolveDocumentGroupId mismatch: TypeId=%s GroupId=%s group_doc_type_id=%s group_name=%s",
|
||||||
|
TypeId, GroupId, row["document_type_id"], row["name"],
|
||||||
|
)
|
||||||
|
raise LeauditException(StatusCodeEnum.HTTP_400_BAD_REQUEST, f"当前子类型「{row['name']}」(id={GroupId}) 属于文档类型 {row['document_type_id']},与所选文档类型 {TypeId} 不匹配,无法上传")
|
||||||
return int(row["id"])
|
return int(row["id"])
|
||||||
|
|
||||||
async def _resolveDocumentRootGroupId(self, Session, TypeId: int, GroupId: int | None) -> int | None:
|
async def _resolveDocumentRootGroupId(self, Session, TypeId: int, GroupId: int | None) -> int | None:
|
||||||
|
|||||||
Reference in New Issue
Block a user