From 88768020bff0321be721dd29e31c5320d21f0622 Mon Sep 17 00:00:00 2001 From: "hehihoho3@gmail.com" Date: Tue, 4 Aug 2026 12:05:05 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20=EA=B3=84=ED=9A=8D=EC=84=9C=20Task=204?= =?UTF-8?q?=20=EC=98=88=EC=8B=9C=20except=20=ED=8A=9C=ED=94=8C=EC=9D=98=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=20=EB=88=84=EC=B6=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 리뷰에서 잡힌 구멍이 계획서 참고 코드에도 그대로 있었다. str.format 의 ValueError 와 .decode 의 UnicodeDecodeError(= ValueError 서브클래스)가 빠져 있어, 그대로 옮기면 "어떤 실패에도 예외 없음" 계약이 깨진다. Co-Authored-By: Claude Opus 5 (1M context) --- docs/superpowers/plans/2026-08-04-컷별-댓글-추천.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/superpowers/plans/2026-08-04-컷별-댓글-추천.md b/docs/superpowers/plans/2026-08-04-컷별-댓글-추천.md index 2b34a2b..5c52695 100644 --- a/docs/superpowers/plans/2026-08-04-컷별-댓글-추천.md +++ b/docs/superpowers/plans/2026-08-04-컷별-댓글-추천.md @@ -502,8 +502,8 @@ def ai_pick_cuts(cuts, comments, quotas, *, model: str = AI_MODEL, try: prompt = prompts.load_recommend().format( cuts=_cut_lines(cuts), comments=_candidate_lines(comments), k=k) - except (KeyError, IndexError, OSError): # 사용자가 프롬프트를 깨뜨린 경우 - return {} + except (KeyError, IndexError, ValueError, OSError): # 사용자가 프롬프트를 깨뜨린 경우 + return {} # ValueError: str.format 은 중괄호가 깨지면 이걸 던진다 body = { "contents": [{"parts": [{"text": prompt}]}], "generationConfig": {"temperature": 0.3, @@ -518,8 +518,9 @@ def ai_pick_cuts(cuts, comments, quotas, *, model: str = AI_MODEL, with urllib.request.urlopen(req, timeout=timeout) as resp: data = json.loads(resp.read().decode("utf-8")) raw = data["candidates"][0]["content"]["parts"][0]["text"] - except (urllib.error.URLError, KeyError, IndexError, TimeoutError, - json.JSONDecodeError, OSError): + # URLError·TimeoutError 는 OSError 서브클래스라 따로 안 적는다. + # ValueError 는 .decode("utf-8") 의 UnicodeDecodeError 를 덮는다(OSError 가 아니다). + except (KeyError, IndexError, json.JSONDecodeError, ValueError, OSError): return {} # 429 포함 — 폴백은 호출부 몫 return _parse_ai(raw) ```