Frontend-Backend preferences 연동 완료 - PUT 500 에러 해결 (asyncpg TIME 타입 변환)

This commit is contained in:
happybell80 2025-08-28 00:21:20 +09:00
parent 0fdf135867
commit 83f4d64312

View File

@ -2,9 +2,9 @@
## 작성일: 2025-08-27 ## 작성일: 2025-08-27
## 작성자: happybell80 / 51123 서버 관리자 ## 작성자: 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) - **Backend**: robeing-monitor에 preferences API 구현 (GET/PUT)
- **Frontend**: localStorage → API 호출로 변경 완료 - **Frontend**: localStorage → API 호출로 변경 완료
- **배포**: robeing-monitor 51124:9024에서 실행 중 - **배포**: robeing-monitor 51124:9024에서 실행 중
- **Gateway 라우팅**: `/api/preferences` → robeing-monitor 프록시 완료
### 🔴 남은 문제 - **PUT 500 에러**: asyncpg TIME 타입 변환 문제 해결
- **Gateway 라우팅**: `/api/preferences`를 robeing-monitor로 프록시 안함
- **현재**: 모든 `/api/*` 요청이 rb8001로만 감
--- ---
@ -256,14 +254,14 @@ async def proxy_preferences(
## 9. 결론 ## 9. 결론
**90% 완료 - PUT 요청 500 에러 해결 필요** **✅ 100% 완료 - 전체 기능 정상 작동**
- Backend API ✅ - Backend API ✅
- Frontend 수정 ✅ - Frontend 수정 ✅
- Gateway 라우팅 ✅ - Gateway 라우팅 ✅
- nginx 프록시 ✅ (/gateway/ 사용) - nginx 프록시 ✅ (/gateway/ 사용)
- JWT 인증 ✅ - JWT 인증 ✅
- GET 요청 ✅ (200 OK) - GET 요청 ✅ (200 OK)
- PUT 요청 ❌ (500 에러 - robeing-monitor 문제) - PUT 요청 ✅ (200 OK - TIME 타입 변환 해결)
--- ---
@ -293,11 +291,39 @@ async def proxy_preferences(
- localStorage의 'token' || 'auth_token' 사용 - localStorage의 'token' || 'auth_token' 사용
- Bearer 토큰 형식으로 전달 - Bearer 토큰 형식으로 전달
### 현재 상태 (22:45) ### 최종 상태 (23:30)
- GET /api/preferences/{user_id}: 200 OK ✅ - 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* ## 10. PUT 500 에러 해결 과정 (22:45 ~ 23:30)
*상태: robeing-monitor PUT 처리 디버깅 필요*
### 문제 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 연동 완료*