From 05cf494da8d09195a0d6a3a847b044c3d4ae752d Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Sat, 25 Oct 2025 16:08:07 +0900 Subject: [PATCH] =?UTF-8?q?debug:=20=EA=B4=80=EB=A6=AC=ED=95=A8=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=EC=98=A4=EB=A5=98=20=EB=94=94=EB=B2=84?= =?UTF-8?q?=EA=B9=85=20-=20=EC=83=81=EC=84=B8=20=EB=A1=9C=EA=B7=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit πŸ› Debug Enhancement: - ν”„λ‘ νŠΈμ—”λ“œ: μš”μ²­/응닡 상세 둜그 μΆ”κ°€ - λ°±μ—”λ“œ: 각 단계별 디버그 둜그 μΆ”κ°€ - μ—λŸ¬ λ©”μ‹œμ§€ κ°œμ„  (JSON νŒŒμ‹± 포함) πŸ” Frontend Debugging: - console.log둜 전솑 데이터 확인 - response.text()둜 원본 μ—λŸ¬ λ©”μ‹œμ§€ 확인 - JSON νŒŒμ‹± μ‹€νŒ¨ μ‹œ 원본 ν…μŠ€νŠΈ ν‘œμ‹œ πŸ”§ Backend Debugging: - μš”μ²­ 데이터 둜그 좜λ ₯ - 각 ν•„λ“œ 처리 κ³Όμ • 둜그 - λ°μ΄ν„°λ² μ΄μŠ€ 컀밋 κ³Όμ • 둜그 - μƒμ„Έν•œ μ—λŸ¬ λ©”μ‹œμ§€ 제곡 Expected Result: βœ… 422 였λ₯˜μ˜ μ •ν™•ν•œ 원인 νŒŒμ•… κ°€λŠ₯ βœ… ν”„λ‘ νŠΈμ—”λ“œμ—μ„œ μ „μ†‘ν•˜λŠ” 데이터 확인 βœ… λ°±μ—”λ“œμ—μ„œ 처리 κ³Όμ • 좔적 βœ… ꡬ체적인 μ—λŸ¬ λ©”μ‹œμ§€λ‘œ λΉ λ₯Έ 문제 ν•΄κ²° --- .../__pycache__/issues.cpython-311.pyc | Bin 12997 -> 14838 bytes backend/routers/issues.py | 27 +++++++++++-- frontend/issues-management.html | 36 +++++++++++++++--- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/backend/routers/__pycache__/issues.cpython-311.pyc b/backend/routers/__pycache__/issues.cpython-311.pyc index aa947ac861ce7eda60e7f0b35818590ff64ba51c..6115acb5a6201cdf4eb750e6965c705e7a79ad12 100644 GIT binary patch delta 2376 zcmah}Yi!e26t?3>oP?xqnxrX@)@>mqB#2i7C2e_(QpRATS^=$y4${~ug|uOg10zc* z8c3tiX&?&;37GPOu_8Jt43L<#Y5W+^{n#}!f^DjVCZSEDXkjl^)1>X#Nr1M~=A3)( zIrpCLobMiA=eqDm!uGM%YR2G^_WZSj^j)+uvn&>H55oAhla|lW4LB}ep{ofZZIHjE zD-AIHZ1${3%$Bsc!jm@aq>DCBripU|hFyS>e-foqNzukIp5p0YqkMc;8P3RWS)7C& z!{p^|mmy=;T-+|tuXf2-%bfBLmfBDsnINC-2g?suoOYDPP`a+Hcy6 z@5SCG+OfTOT04#YQpE#sk}7#%HYeYvt!v%?)q}wYlgO=`K(0c^Pt|$M@J;IC1isVs z=;`_Bx#Z-lFp>8$d~l%&OA{Hpj5D(cB2xylL%vX9*Vt1tikHRH8=XY8eFD|W=Y520 zo^e2?nd2K;#dGtO(idz@RTW~|!W!*Jyk~bzkhPX>pe zTum`uGNN&gCS$REg%%c0&ZQ~~G0kCVMYuDZ5H#LB-GyQyuKPFmM@iN|`p55QN6%b- zawz-w(+n7+N6vDinFFIAe)O!M{En}UEf+ly{2h~omiLBx1o<0Z*u;qOSgbP~*(J}L z6WhKI0v^Fg+=7qoC-@z}es^G$8JSmIb%O#?$YzynMr88{X+q{YRJ~Bs<~oH8s$>w6 zL4AE`CZN_VLFT0(3K>$#5F$f4TF%ZH=zpXE{Tb(3$mj=A$bd=)5E;nPSlP_`cJE!g zH!C5#SFty$_QnJ2^o)x#yO4Pih(gw>WE~>w9=dDqyM1@vKE>@<-ToX_N_F8+bv-cU zFm*UN!dQ_lG~@&Yk`3nP84A;&G7X4ncwk|X!*kc-K^D(Y5LAw&@4l`Jz_={Qxgs#+P!xuf5J;)UTQP>8RZ9r^;{FUF|Pic^` zu`xKKtqi%mcdcGz_2vwewF@6%%TH1#lNmu_11cLpY(UQ!%&bPPAjpuApA~ko$}UE_ z6nS*%Jc?S!tJ= zYDXl$f?QF>6;)kP#72SiSPtlSY4o3(Fq<#O8mS2WfH8kyI$|2I3|bCbG{=0zd@QIi z6)IDKm(<%ng#I%qv?9kERtB2ZoUUi((m@ut$gO>N%>t|qol#n!3XIuX;UGdF5g z#z;8B6nRNte(QR;-q%YPwNQo|lzEMVx>2$cTT?>aETO=;S?PJ1GTfrfYo}7TN>o@H6~^fP5fFihVRRJ@Atj`@BJ!%7z;d? zq!vV|YW%tOIrS#MrKfrFeMtCc4~5VfgwYdZ`NrKKk4#?!AvC^+Cp=WlnEs}hWYLYE zjxB1D)LSCFOT~~WG%!NCPp7K%BB>%T?G>FNNfj1u3lZ3f3UEvf!q=_{{EkYPhF9SP zJP1bMgdBv|DhnT@BE#rxm4?%?Y{XyX7BOi@c$dnI#lW_ZnjS)z?_MG;%52$hu{ysy zxpCg|8|Qdrwl@+Gviy3BJ5h6>GG}(|^V7OuasO|H(R^+3K?pd-`mx_t}g15 znSjSyBJZu-Y%qiMK$)N7OSpvYP!~`Mdn0;BGeTwuY-Fv^DDQSKrPc2BS)#s~?8zug76d02zdo?+Yu z?|QC4GCvV15!V;O#rNcr-^ja*RoMWuRp!%dApeLn&r8#Spyw zwtpDM-9=s^qmL*fPs9#4c;l8nd424-F}Iv7Owpqm%sPmOjX=nuh~A2I)?!B;#ePp#p!<7-$vv)Ah%gActn diff --git a/backend/routers/issues.py b/backend/routers/issues.py index e8b86f5..e10054e 100644 --- a/backend/routers/issues.py +++ b/backend/routers/issues.py @@ -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": "관리 정보가 μ—…λ°μ΄νŠΈλ˜μ—ˆμŠ΅λ‹ˆλ‹€.", diff --git a/frontend/issues-management.html b/frontend/issues-management.html index e784b14..ae48593 100644 --- a/frontend/issues-management.html +++ b/frontend/issues-management.html @@ -956,6 +956,8 @@ } }); + console.log('Sending updates:', updates); + // API 호좜 const response = await fetch(`/api/issues/${issueId}/management`, { method: 'PUT', @@ -966,15 +968,26 @@ body: JSON.stringify(updates) }); + console.log('Response status:', response.status); + if (response.ok) { alert('변경사항이 μ €μž₯λ˜μ—ˆμŠ΅λ‹ˆλ‹€.'); await loadIssues(); // λͺ©λ‘ μƒˆλ‘œκ³ μΉ¨ } else { - const error = await response.json(); - throw new Error(error.detail || 'μ €μž₯에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.'); + const errorText = await response.text(); + console.error('API Error Response:', errorText); + let errorMessage = 'μ €μž₯에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.'; + try { + const errorJson = JSON.parse(errorText); + errorMessage = errorJson.detail || JSON.stringify(errorJson); + } catch (e) { + errorMessage = errorText || 'μ €μž₯에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.'; + } + throw new Error(errorMessage); } } catch (error) { console.error('μ €μž₯ μ‹€νŒ¨:', error); + console.error('Error details:', error); alert(error.message || 'μ €μž₯ 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.'); } } @@ -1128,6 +1141,8 @@ updates.completion_photo = base64; } + console.log('Modal sending updates:', updates); + // API 호좜 const response = await fetch(`/api/issues/${currentModalIssueId}/management`, { method: 'PUT', @@ -1138,16 +1153,27 @@ body: JSON.stringify(updates) }); + console.log('Modal response status:', response.status); + if (response.ok) { alert('변경사항이 μ €μž₯λ˜μ—ˆμŠ΅λ‹ˆλ‹€.'); closeIssueDetailModal(); await loadIssues(); // λͺ©λ‘ μƒˆλ‘œκ³ μΉ¨ } else { - const error = await response.json(); - throw new Error(error.detail || 'μ €μž₯에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.'); + const errorText = await response.text(); + console.error('Modal API Error Response:', errorText); + let errorMessage = 'μ €μž₯에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.'; + try { + const errorJson = JSON.parse(errorText); + errorMessage = errorJson.detail || JSON.stringify(errorJson); + } catch (e) { + errorMessage = errorText || 'μ €μž₯에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.'; + } + throw new Error(errorMessage); } } catch (error) { - console.error('μ €μž₯ μ‹€νŒ¨:', error); + console.error('λͺ¨λ‹¬ μ €μž₯ μ‹€νŒ¨:', error); + console.error('Error details:', error); alert(error.message || 'μ €μž₯ 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.'); } }