fix(web): normalize chat user id fields for own-message rendering#484
fix(web): normalize chat user id fields for own-message rendering#484
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Walkthrough이 변경사항은 채팅 API 계층에서 원본 데이터 정규화 처리를 도입합니다. 새로운 Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 상세 변경 사항
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/web/src/lib/web-socket/useConnectWebSocket.ts (1)
57-65: 정규화 로직이 잘 적용되었으나, 빈 catch 블록은 개선이 필요합니다.
정규화 적용 - 좋습니다:
normalizeChatMessage()를 통해 WebSocket 메시지도 API 응답과 동일한 정규화 처리를 받습니다.createdAt 검증 - 훌륭합니다:
- 유효하지 않은 날짜에 대한 방어적 코딩이 적용되어 있습니다.
빈 catch 블록 - 개선 권장:
- 파싱 실패 시 완전히 무시되어 디버깅이 어려울 수 있습니다.
♻️ 최소한의 로깅 추가 제안
} catch (error) { + console.warn("[WebSocket] Failed to parse message:", error); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/src/lib/web-socket/useConnectWebSocket.ts` around lines 57 - 65, The catch block swallowing JSON parse/normalize errors needs a minimal logging/diagnostic step: in the try/catch inside useConnectWebSocket where you parse and normalize messages (normalizeChatMessage, setSubmittedMessages), replace the empty catch with code that logs the error and context (at least the caught error and message.body or a summarized payload) using the existing logger or console.error so parsing failures are visible for debugging; keep the defensive createdAt fix and do not rethrow, just ensure the catch records error details and context.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/web/src/lib/web-socket/useConnectWebSocket.ts`:
- Around line 57-65: The catch block swallowing JSON parse/normalize errors
needs a minimal logging/diagnostic step: in the try/catch inside
useConnectWebSocket where you parse and normalize messages
(normalizeChatMessage, setSubmittedMessages), replace the empty catch with code
that logs the error and context (at least the caught error and message.body or a
summarized payload) using the existing logger or console.error so parsing
failures are visible for debugging; keep the defensive createdAt fix and do not
rethrow, just ensure the catch records error details and context.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 91f71cd0-8d4b-4c3b-9e23-bb8f1eed825b
📒 Files selected for processing (5)
apps/web/src/apis/chat/api.tsapps/web/src/apis/chat/normalize.tsapps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/index.tsxapps/web/src/lib/web-socket/useConnectWebSocket.tsapps/web/src/utils/jwtUtils.ts
Background
senderIdvssiteUserId) and tokensubtype mismatch (string/number).What I changed
senderIdandsiteUserId.subacceptnumber | stringand converted to numeric user id in chat content.Bruno-based verification
siteUserIdin message payload.siteUserIdfor partner id.subas string.Validation