Skip to content

[fix] 채팅방 질문 추천 API LazyInitializationException 수정#396

Merged
sgo722 merged 1 commit intodevelopfrom
feature/#395
Feb 1, 2026
Merged

[fix] 채팅방 질문 추천 API LazyInitializationException 수정#396
sgo722 merged 1 commit intodevelopfrom
feature/#395

Conversation

@sgo722
Copy link
Contributor

@sgo722 sgo722 commented Feb 1, 2026

Summary

  • 채팅방 질문 추천 API 호출 시 발생하던 LazyInitializationException 오류 수정
  • DTO 스펙 변경 없이 Controller에서 응답 구성 방식 변경

Problem

QuestionRecommendResponseV2["chat"]
  → SavedChatDto["partner"]
    → Member["profile"]
      → Profile["codeImages"]  ← LazyInitializationException
  • SavedChatDto.partner: Member 엔티티가 HTTP 응답에 포함됨
  • Jackson 직렬화 시 Lazy 컬렉션 접근 → 세션 종료 후 에러 발생

Solution

// Before
response  // SavedChatDto 포함 → Member 직렬화 시도

// After
ResponseEntity.ok(mapOf(
    "success" to body.success,
    "question" to body.question,
    "chat" to body.chat?.chatResponse,  // ChatResponse만 포함
    "exhaustedMessage" to body.exhaustedMessage
))

Test plan

  • 채팅방 질문 추천 API 호출 시 500 에러 발생하지 않음 확인
  • 응답에 success, question, chat, exhaustedMessage 필드 정상 포함 확인
  • WebSocket 메시지 정상 전송 확인

Closes #395

🤖 Generated with Claude Code

- QuestionRecommendResponseV2 응답 시 Map으로 직접 구성
- SavedChatDto.partner: Member 직렬화 방지
- chat 필드에 ChatResponse만 포함하여 Lazy 로딩 문제 해결

Closes #395

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sgo722 sgo722 merged commit f210600 into develop Feb 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] 채팅방 질문 추천 API LazyInitializationException 오류 수정

1 participant