From 52733df2356c9a11f91ac4fca1b1edf2ba4f6e88 Mon Sep 17 00:00:00 2001 From: claude-owner Date: Thu, 28 May 2026 19:29:49 +0900 Subject: [PATCH] =?UTF-8?q?fix(fundamentals):=20logger.exception=20?= =?UTF-8?q?=E2=86=92=20logger.error=20%r=20(UnicodeDecodeError=20=ED=9A=8C?= =?UTF-8?q?=EA=B7=80=20=EB=B0=A9=EC=A7=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pykrx/KRX 비정상 응답에서 traceback 포매팅 중 UnicodeDecodeError 가 발생해 API 500 을 만든 회귀 사례가 있었음. 새 pykrx fundamentals 경로에 동일 패턴이 다시 들어가지 않도록 %r 안전 직렬화로 통일. --- backend/app/fetch/fundamentals.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/app/fetch/fundamentals.py b/backend/app/fetch/fundamentals.py index a2db16d..97f2e21 100644 --- a/backend/app/fetch/fundamentals.py +++ b/backend/app/fetch/fundamentals.py @@ -63,8 +63,10 @@ def _fetch_one(code: str, target: date) -> Fundamentals | None: try: cap_df = krx.get_market_cap(ds, ds, code) fund_df = krx.get_market_fundamental(ds, ds, code) - except Exception: # noqa: BLE001 - logger.exception("pykrx fundamentals failed code=%s date=%s", code, ds) + except Exception as exc: # noqa: BLE001 + # logger.exception 은 예전에 pykrx/KRX 비정상 응답 traceback 포매팅 중 + # UnicodeDecodeError 로 API 500 을 만든 적이 있음 → %r 로 안전하게 직렬화. + logger.error("pykrx fundamentals failed code=%s date=%s err=%r", code, ds, exc) return None cap_ok = cap_df is not None and not cap_df.empty