From 83f4d64312084164fdf3517d695a0638eb43303e Mon Sep 17 00:00:00 2001 From: happybell80 Date: Thu, 28 Aug 2025 00:21:20 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Frontend-Backend=20preferences=20?= =?UTF-8?q?=EC=97=B0=EB=8F=99=20=EC=99=84=EB=A3=8C=20-=20PUT=20500=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=ED=95=B4=EA=B2=B0=20(asyncpg=20TIME=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EB=B3=80=ED=99=98)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ntend_backend_user_preferences_mismatch.md | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/troubleshooting/250827_frontend_backend_user_preferences_mismatch.md b/troubleshooting/250827_frontend_backend_user_preferences_mismatch.md index 3e67f2a..9b60eda 100644 --- a/troubleshooting/250827_frontend_backend_user_preferences_mismatch.md +++ b/troubleshooting/250827_frontend_backend_user_preferences_mismatch.md @@ -2,9 +2,9 @@ ## 작성일: 2025-08-27 ## 작성자: happybell80 / 51123 서버 관리자 -## 상태: 🟡 진행중 - Gateway 라우팅 추가 필요 +## 상태: ✅ 완료 - 2025-08-27 23:30 ## 영향: 사용자 설정 기능 연동 -## 최종 업데이트: 2025-08-27 22:00 +## 최종 업데이트: 2025-08-27 23:30 --- @@ -14,10 +14,8 @@ - **Backend**: robeing-monitor에 preferences API 구현 (GET/PUT) - **Frontend**: localStorage → API 호출로 변경 완료 - **배포**: robeing-monitor 51124:9024에서 실행 중 - -### 🔴 남은 문제 -- **Gateway 라우팅**: `/api/preferences`를 robeing-monitor로 프록시 안함 -- **현재**: 모든 `/api/*` 요청이 rb8001로만 감 +- **Gateway 라우팅**: `/api/preferences` → robeing-monitor 프록시 완료 +- **PUT 500 에러**: asyncpg TIME 타입 변환 문제 해결 --- @@ -256,14 +254,14 @@ async def proxy_preferences( ## 9. 결론 -**90% 완료 - PUT 요청 500 에러 해결 필요** +**✅ 100% 완료 - 전체 기능 정상 작동** - Backend API ✅ - Frontend 수정 ✅ - Gateway 라우팅 ✅ - nginx 프록시 ✅ (/gateway/ 사용) - JWT 인증 ✅ - GET 요청 ✅ (200 OK) -- PUT 요청 ❌ (500 에러 - robeing-monitor 문제) +- PUT 요청 ✅ (200 OK - TIME 타입 변환 해결) --- @@ -293,11 +291,39 @@ async def proxy_preferences( - localStorage의 'token' || 'auth_token' 사용 - Bearer 토큰 형식으로 전달 -### 현재 상태 (22:45) +### 최종 상태 (23:30) - GET /api/preferences/{user_id}: 200 OK ✅ -- PUT /api/preferences/{user_id}: 500 에러 (robeing-monitor 내부 문제) +- PUT /api/preferences/{user_id}: 200 OK ✅ --- -*최종 수정: 2025-08-27 22:45* -*상태: robeing-monitor PUT 처리 디버깅 필요* \ No newline at end of file +## 10. PUT 500 에러 해결 과정 (22:45 ~ 23:30) + +### 문제 1: 존재하지 않는 컬럼 참조 +- **원인**: INSERT/UPDATE 쿼리가 DB에 없는 컬럼 참조 +- **해결**: schedule_type, schedule_days, include_* 컬럼 제거 + +### 문제 2: Frontend 필드명 불일치 +- **원인**: Frontend(keywords) vs Backend(news_keywords) +- **해결**: 필드명 자동 매핑 구현 + +### 문제 3: TIME 타입 변환 실패 (핵심) +- **원인**: asyncpg에서 문자열 + ::time 캐스팅 처리 실패 +- **잘못된 방법**: +```python +"briefing_time = $2::time" +params.append("08:30:00") # 문자열 +``` +- **올바른 방법**: +```python +from datetime import datetime +time_obj = datetime.strptime("08:30:00", "%H:%M:%S").time() +"briefing_time = $2" # ::time 제거 +params.append(time_obj) # datetime.time 객체 +``` +- **핵심**: asyncpg는 Python datetime.time 객체를 PostgreSQL TIME으로 자동 변환 + +--- + +*최종 수정: 2025-08-27 23:30* +*상태: ✅ 완전 해결 - Frontend-Backend preferences 연동 완료* \ No newline at end of file