From ebc37961e0d4fa9209944e1cae8ce3b4574e4b70 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Fri, 24 Apr 2026 10:19:33 +0900 Subject: [PATCH] fix(memo): prevent title overwrite on checkbox patch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 체크박스 토글 같은 {content}-only PATCH 에서 body.title==None 을 무조건 _auto_title(content)로 재생성해 제목이 체크박스 라인으로 덮어씌워지는 버그. Pydantic model_fields_set 으로 title 전송 여부를 구분해 PATCH semantics 정상화. --- app/api/memos.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/api/memos.py b/app/api/memos.py index 9c94b47..0fd4cf5 100644 --- a/app/api/memos.py +++ b/app/api/memos.py @@ -243,7 +243,14 @@ async def update_memo( doc.extracted_text = content doc.file_hash = _content_hash(content) doc.file_size = len(content.encode("utf-8")) - doc.title = body.title.strip() if body.title and body.title.strip() else _auto_title(content) + # PATCH semantics: title 필드를 명시적으로 보낸 경우만 덮어쓴다. + # 체크박스 토글 경로처럼 {content}만 PATCH 하면 기존 title을 보존해야 함 + # (이전엔 None→_auto_title(content)로 제목이 체크박스 라인으로 덮어씌워지는 버그). + if "title" in body.model_fields_set: + doc.title = body.title.strip() if body.title and body.title.strip() else _auto_title(content) + elif not (doc.title or "").strip(): + # 기존 title이 비어 있던 경우만 보강 + doc.title = _auto_title(content) doc.user_tags = _parse_hashtags(content) # stale AI 데이터 즉시 초기화