[Fix/#235] 2차 과제 피드백 적용 - #236
Conversation
WalkthroughAI 질문 재생성 및 질문-일기 연결 API를 제거했습니다. Gemini의 빈 응답과 JSON 파싱 오류를 명시적 예외로 처리했습니다. 관련 AI API의 Swagger 500 응답 문서를 오류 코드별 예시로 확장했습니다. ChangesAI API 및 오류 처리
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/ai/services/ai-gemini.service.ts`:
- Around line 33-41: Update requireAiText to trim the received text before
validating it, throw InternalServerException with AI_EMPTY_RESPONSE when the
trimmed value is empty, and return the trimmed value so generateTodayQuestion
and generateAnswer handle whitespace-only responses consistently.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2f5622b6-2da5-43a5-8532-ec5c933ca267
📒 Files selected for processing (5)
src/ai/ai.controller.tssrc/ai/ai.swagger.tssrc/ai/dto/ai-diary-question.dto.tssrc/ai/services/ai-gemini.service.tssrc/ai/services/ai-question.service.ts
💤 Files with no reviewable changes (1)
- src/ai/dto/ai-diary-question.dto.ts
| function requireAiText(text: string | undefined): string { | ||
| if (!text) { | ||
| throw new InternalServerException( | ||
| 'AI가 빈 응답을 반환했습니다.', | ||
| 'AI_EMPTY_RESPONSE', | ||
| ); | ||
| } | ||
|
|
||
| return text; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
공백 전용 AI 응답도 AI_EMPTY_RESPONSE로 처리하세요.
" "와 "\n"은 truthy입니다. 따라서 generateTodayQuestion과 generateAnswer는 .trim() 후 빈 문자열을 성공 값으로 반환합니다. 추천 API는 같은 입력을 AI_RESPONSE_PARSE_ERROR로 반환합니다.
requireAiText에서 먼저 trim()한 값을 검사하고 반환하세요.
수정 예시
function requireAiText(text: string | undefined): string {
- if (!text) {
+ const normalizedText = text?.trim();
+
+ if (!normalizedText) {
throw new InternalServerException(
'AI가 빈 응답을 반환했습니다.',
'AI_EMPTY_RESPONSE',
);
}
- return text;
+ return normalizedText;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| function requireAiText(text: string | undefined): string { | |
| if (!text) { | |
| throw new InternalServerException( | |
| 'AI가 빈 응답을 반환했습니다.', | |
| 'AI_EMPTY_RESPONSE', | |
| ); | |
| } | |
| return text; | |
| function requireAiText(text: string | undefined): string { | |
| const normalizedText = text?.trim(); | |
| if (!normalizedText) { | |
| throw new InternalServerException( | |
| 'AI가 빈 응답을 반환했습니다.', | |
| 'AI_EMPTY_RESPONSE', | |
| ); | |
| } | |
| return normalizedText; | |
| } |
🤖 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 `@src/ai/services/ai-gemini.service.ts` around lines 33 - 41, Update
requireAiText to trim the received text before validating it, throw
InternalServerException with AI_EMPTY_RESPONSE when the trimmed value is empty,
and return the trimmed value so generateTodayQuestion and generateAnswer handle
whitespace-only responses consistently.
📌 관련 이슈번호
(Closes 키워드가 있어야 PR이 머지되었을 때 이슈가 자동으로 닫힌다)
📌 PR 유형
어떤 변경 사항이 있나요?
📌 PR 요약
해당 PR을 간단하게 요약해 주세요
📌 작업 세부 내용
📸 스크린샷 (선택)
🔗 참고 자료