refactor: 에러 문구를 서버 detail 기반으로 통일 + 이미지 5MB 사전검증#320
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Discord 스레드 연동용 메타데이터입니다. discord-pr-bot 워크플로가 자동 생성하며, 수정·삭제하면 PR 과 Discord 알림 연동이 끊깁니다. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughChangesAPI 에러 메시지 처리
이미지 업로드 사전 용량검증
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/web/src/utils/getApiErrorMessage.ts (1)
1-22: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win유닛 테스트 부재
정책 분기(상태코드 경계값 500, detail 존재/부재, non-axios 에러)가 여러 개인 공통 유틸인데 테스트가 없습니다. 여러 화면에서 공유되는 만큼 회귀 방지를 위한 테스트 추가를 고려해주세요.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/utils/getApiErrorMessage.ts` around lines 1 - 22, Add unit tests for getApiErrorMessage to cover the policy branches: axios errors with response status below 500 and a detail should return that detail, 500+ responses should fall back, missing detail should fall back, and non-Axios errors should also return the fallback. Use getApiErrorMessage and DEFAULT_ERROR_MESSAGE as the main targets so the shared utility’s behavior stays locked down against regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/web/src/utils/getApiErrorMessage.ts`:
- Around line 1-22: Add unit tests for getApiErrorMessage to cover the policy
branches: axios errors with response status below 500 and a detail should return
that detail, 500+ responses should fall back, missing detail should fall back,
and non-Axios errors should also return the fallback. Use getApiErrorMessage and
DEFAULT_ERROR_MESSAGE as the main targets so the shared utility’s behavior stays
locked down against regressions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ab0430b5-e624-4823-afc0-8df761980c5e
📒 Files selected for processing (7)
apps/web/src/app/mypage/edit/_hooks/usePatchMe.tsapps/web/src/app/mypage/withdraw/_hooks/useDeleteMe.tsapps/web/src/app/tournament/[id]/create/_components/invite-friends/InviteFriendsDialog.tsxapps/web/src/app/tournament/[id]/create/by-wish/_hooks/usePostTournamentItemsByWish.tsapps/web/src/app/tournament/[id]/result/_components/plate-share-dialog/PlateShareDialog.tsxapps/web/src/hooks/useImagePicker.tsapps/web/src/utils/getApiErrorMessage.ts
There was a problem hiding this comment.
이거 새로 생성하지말고 pull 한번 받아서 작업해줄래??
…sage-policy # Conflicts: # apps/web/src/utils/getApiErrorMessage.ts
| export const getApiErrorMessage = (error: unknown, fallback?: string): string => { | ||
| if (isAxiosError<ApiErrorResponseT>(error)) { | ||
| const status = error.response?.status; | ||
|
|
||
| if (!status || status >= 500) return '일시적인 오류예요. 잠시 후 다시 시도해 주세요.'; | ||
| return error.response?.data?.detail ?? '요청을 처리하지 못했어요.'; | ||
| if (!status || status >= 500) | ||
| return fallback ?? '일시적인 오류예요. 잠시 후 다시 시도해 주세요.'; | ||
| return error.response?.data?.detail ?? fallback ?? '요청을 처리하지 못했어요.'; |
There was a problem hiding this comment.
p4) fallback은 제거하는 게 좋아보인당
이 유틸함수의 역할이 에러 → 에러 메시지 추출 규칙 공통화인데 fallback을 사용하게 되면 호출 포인트마다 문구가 달라질 수 있어서 통일하기가 어려울 것 같아
* refactor: 에러 문구를 서버 detail 기반으로 통일 + 이미지 5MB 사전검증 * refactor: getApiErrorMessage fallback 파라미터 제거 (문구 통일)
작업 요약
detail기반으로 통일합니다 (에러 메시지 정책 status 뭉뚱그림 개선 + 413 사전검증 #305)getApiErrorMessage를 도입합니다작업 세부 내용
1.
getApiErrorMessage유틸 도입 —src/utils/getApiErrorMessage.ts이슈에서 합의된 정책을 코드로 반영:
detail을 그대로 노출 — 문구의 SSOT 는 서버 (프론트 code 매핑 X)detail이 사용자용 문구가 아니므로 fallback 사용'마감 시각을 변경하지 못했어요.')2. 하드코딩 고정 문구 →
detail교체 (4곳)usePostTournamentItemsByWish'위시템 추가에 실패했어요...'고정getApiErrorMessage(error, ...)InviteFriendsDialog마감 수정'마감 시각을 변경하지 못했어요.'고정getApiErrorMessage(error, ...)PlateShareDialog플레이 링크 생성'공유 링크를 생성하지 못했어요...'고정getApiErrorMessage(error, ...)useDeleteMe회원 탈퇴'잠시 후 다시 시도해주세요.'고정getApiErrorMessage(error, ...)이제 만료/권한/중복 등 원인이 다른 실패에 서버가 내려주는 구체적 문구가 그대로 노출됩니다.
참고:
usePostTournamentItemsByWish의 onError 삭제 (전역 안전망 위임) 옵션은 선행 이슈 #299 가 아직 미구현이라 보류 — 삭제 시 silent failure 가 되므로 #299 머지 후 후속 처리.3.
usePatchMe견고화기존엔 axios 에러가 아니거나 response 가 없으면 (네트워크 오류) 토스트 없이 조용히 실패 →
getApiErrorMessage로 교체해 항상 사용자 피드백이 보장됩니다.4. 이미지 업로드 5MB 사전검증 —
useImagePicker공통 적용handleImagesSelect공통 경로에서 5MB 초과 파일을 업로드 전에 필터 + 안내 토스트skippedCount는 "지원하지 않는 형식" 의미라 합치지 않고 별도 토스트로 분리연관 이슈
closes #305
Summary by CodeRabbit