fix(M02): 층 길 저장 PUT 이 뼈대 없는 문서(빈 {} · 표 열 목록 없음 · 도면 entities 없음)를 400 으로 거절 — 파일 안 씀 (브레인 급한 흠)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LuapLYqN1GGFD8Y1PStD5
This commit is contained in:
@@ -253,6 +253,10 @@ async def save_layer_template(
|
||||
) -> dict[str, Any]:
|
||||
folder = await _layer_dir(session, layer, project_id=project_id, write=True)
|
||||
document = body.문서
|
||||
try:
|
||||
layers.check_skeleton(kind, document) # 빈 `{}` · 뼈대 없는 문서는 파일 안 씀
|
||||
except ValueError as error:
|
||||
raise _bad(error) from error
|
||||
if kind == "table" and fill.is_fillable(document):
|
||||
# 채운 표가 와도 설계값은 안 받아 적음 — 양식 + 손 값만(5장 · 브라우저 값을 믿지 않음)
|
||||
document = fill.strip_design(document)
|
||||
|
||||
@@ -159,6 +159,15 @@ def read_template(layer_dir: str | Path, kind: str, name: str) -> dict[str, Any]
|
||||
}
|
||||
|
||||
|
||||
def check_skeleton(kind: str, document: Any) -> None:
|
||||
"""뼈대 없는 문서는 거절 — 표 = `열` 목록 · 도면 = `entities` 목록(빈 `{}` 저장 막기)."""
|
||||
key = {"table": "열", "drawing": "entities"}.get(kind)
|
||||
if not isinstance(document, dict):
|
||||
raise ValueError("양식 문서는 JSON 객체여야 합니다.")
|
||||
if key and not isinstance(document.get(key), list):
|
||||
raise ValueError(f"양식 문서에 `{key}` 목록이 없습니다 — 빈 문서는 저장하지 않습니다.")
|
||||
|
||||
|
||||
def write_template(
|
||||
layer_dir: str | Path,
|
||||
kind: str,
|
||||
|
||||
Reference in New Issue
Block a user