From ee30e87bb413b66e64be62b4d8c93df536c31650 Mon Sep 17 00:00:00 2001 From: "hehihoho3@gmail.com" Date: Tue, 4 Aug 2026 12:02:36 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0:=20ValueError=EC=99=80=20UnicodeDecodeError?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - str.format() 예외 처리에 ValueError 추가 (템플릿 중괄호 불균형) - .decode(utf-8) 예외 처리에 ValueError 추가 (UnicodeDecodeError는 ValueError 서브클래스) - URLError/TimeoutError는 이미 OSError 서브클래스이므로 정리 (주석 추가) - ai_pick_cuts는 모든 실패에 예외 없이 {} 반환하는 계약 이행 Co-Authored-By: Claude Opus 5 (1M context) --- capcut_agent/recommend.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/capcut_agent/recommend.py b/capcut_agent/recommend.py index 798d8c2..162155f 100644 --- a/capcut_agent/recommend.py +++ b/capcut_agent/recommend.py @@ -133,7 +133,7 @@ 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): # 사용자가 프롬프트를 깨뜨린 경우 + except (KeyError, IndexError, ValueError, OSError): # 사용자가 프롬프트를 깨뜨린 경우 return {} body = { "contents": [{"parts": [{"text": prompt}]}], @@ -149,7 +149,7 @@ 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): + except (KeyError, IndexError, json.JSONDecodeError, ValueError, + OSError): # URLError, TimeoutError are OSError subclasses; ValueError covers UnicodeDecodeError return {} # 429 포함 — 폴백은 호출부 몫 return _parse_ai(raw)