debug: 관리함 저장 오류 디버깅 - 상세 로그 추가
🐛 Debug Enhancement: - 프론트엔드: 요청/응답 상세 로그 추가 - 백엔드: 각 단계별 디버그 로그 추가 - 에러 메시지 개선 (JSON 파싱 포함) 🔍 Frontend Debugging: - console.log로 전송 데이터 확인 - response.text()로 원본 에러 메시지 확인 - JSON 파싱 실패 시 원본 텍스트 표시 🔧 Backend Debugging: - 요청 데이터 로그 출력 - 각 필드 처리 과정 로그 - 데이터베이스 커밋 과정 로그 - 상세한 에러 메시지 제공 Expected Result: ✅ 422 오류의 정확한 원인 파악 가능 ✅ 프론트엔드에서 전송하는 데이터 확인 ✅ 백엔드에서 처리 과정 추적 ✅ 구체적인 에러 메시지로 빠른 문제 해결
This commit is contained in:
Binary file not shown.
@@ -236,6 +236,10 @@ async def update_issue_management(
|
||||
"""
|
||||
관리함에서 이슈의 관리 관련 필드들을 업데이트합니다.
|
||||
"""
|
||||
print(f"DEBUG: Received management update for issue {issue_id}")
|
||||
print(f"DEBUG: Update data: {management_update}")
|
||||
print(f"DEBUG: Current user: {current_user.username}")
|
||||
|
||||
# 관리함 페이지 권한 확인
|
||||
if not (current_user.role == UserRole.admin or check_page_access(current_user.id, 'issues_management', db)):
|
||||
raise HTTPException(status_code=403, detail="관리함 접근 권한이 없습니다.")
|
||||
@@ -245,22 +249,39 @@ async def update_issue_management(
|
||||
if not issue:
|
||||
raise HTTPException(status_code=404, detail="부적합을 찾을 수 없습니다.")
|
||||
|
||||
print(f"DEBUG: Found issue: {issue.id}")
|
||||
|
||||
# 관리함에서만 수정 가능한 필드들만 업데이트
|
||||
update_data = management_update.dict(exclude_unset=True)
|
||||
print(f"DEBUG: Update data dict: {update_data}")
|
||||
|
||||
for field, value in update_data.items():
|
||||
print(f"DEBUG: Processing field {field} = {value}")
|
||||
if field == 'completion_photo' and value:
|
||||
# 완료 사진 업로드 처리
|
||||
try:
|
||||
completion_photo_path = save_base64_image(value, "completion")
|
||||
setattr(issue, 'completion_photo_path', completion_photo_path)
|
||||
print(f"DEBUG: Saved completion photo: {completion_photo_path}")
|
||||
except Exception as e:
|
||||
print(f"DEBUG: Photo save error: {str(e)}")
|
||||
raise HTTPException(status_code=400, detail=f"완료 사진 저장 실패: {str(e)}")
|
||||
elif field != 'completion_photo': # completion_photo는 위에서 처리됨
|
||||
setattr(issue, field, value)
|
||||
try:
|
||||
setattr(issue, field, value)
|
||||
print(f"DEBUG: Set {field} = {value}")
|
||||
except Exception as e:
|
||||
print(f"DEBUG: Field set error for {field}: {str(e)}")
|
||||
raise HTTPException(status_code=400, detail=f"필드 {field} 설정 실패: {str(e)}")
|
||||
|
||||
db.commit()
|
||||
db.refresh(issue)
|
||||
try:
|
||||
db.commit()
|
||||
db.refresh(issue)
|
||||
print(f"DEBUG: Successfully updated issue {issue.id}")
|
||||
except Exception as e:
|
||||
print(f"DEBUG: Database commit error: {str(e)}")
|
||||
db.rollback()
|
||||
raise HTTPException(status_code=500, detail=f"데이터베이스 저장 실패: {str(e)}")
|
||||
|
||||
return {
|
||||
"message": "관리 정보가 업데이트되었습니다.",
|
||||
|
||||
Reference in New Issue
Block a user