Skip to content

fix: improve 답변 Null로 반환하는 이슈 해결 - #21

Merged
hgeniee merged 3 commits into
mainfrom
feature/#17-fix
Jun 6, 2026
Merged

hgeniee merged 3 commits into
mainfrom
feature/#17-fix

Conversation

@hgeniee

@hgeniee hgeniee commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

✨ 관련된 이슈

🙌 작업 내용

  • improve 답변 Null로 반환하는 이슈 해결

📸 스크린샷 (선택)

🤔 리뷰 요구사항(선택)

Summary by CodeRabbit

  • 개선사항

    • AI 피드백의 개선 메시지가 비어있거나 누락된 경우 기본 메시지로 자동 채워집니다.
  • 새 기능

    • 개인정보 감지 결과를 반환하는 전용 응답 구조가 추가되었습니다.
    • 프로젝트 세션 생성 시 코드 내 개인정보 감지 시 생성을 차단합니다.
  • 행동 변경

    • 면접 최종 제출 흐름은 개인정보 감지 시 즉시 차단하지 않고 정상 처리로 변경되었습니다.
  • 테스트

    • 관련 단위 테스트들이 추가·수정되어 위 동작들을 검증합니다.
  • 문서

    • 일부 API 설명(메타데이터)이 업데이트되었습니다.

@hgeniee hgeniee self-assigned this Jun 6, 2026
@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

Need an answer fast? Review this PR in Change Stack to ask focused questions about the PR or a changed range.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 11f2f06e-2d77-4ea5-9d92-f6d63606c52e

📥 Commits

Reviewing files that changed from the base of the PR and between 1023149 and 7e02897.

📒 Files selected for processing (1)
  • src/test/java/com/example/trouble_log/domain/projectSession/service/ProjectSessionServiceTest.java

📝 Walkthrough

Walkthrough

이 PR은 AI 피드백의 improvement가 null/공백일 때 기본 메시지로 치환하는 로직을 도입하고, InterviewSubmissionService에서 개인정보 검출을 제거하며 ProjectSessionService에 코드 콘텐츠 개인정보 검증을 추가하고 관련 DTO/OpenAPI/예외 처리와 테스트를 갱신합니다.

Changes

개선문구 정규화 및 개인정보 검출 흐름 변경

Layer / File(s) Summary
Improvement 정규화 및 테스트
src/main/java/.../InterviewService.java, src/test/java/.../InterviewServiceTest.java
DEFAULT_IMPROVEMENT_MESSAGE 상수와 normalizeImprovement 메서드를 추가하고 saveAnswer에서 improvement를 정규화하여 대입합니다. 관련 테스트(setUp 정리, null/blank 케이스)를 추가/수정했습니다.
InterviewSubmissionController OpenAPI 메타데이터 조정
src/main/java/.../InterviewSubmissionController.java
컨트롤러의 @Tag/@Operation/@ApiResponse 설명을 개인정보 검출 시점 및 400 응답 설명 변경으로 갱신했습니다.
PersonalInfoDetectionResponse DTO 및 글로벌 예외처리 업데이트
src/main/java/.../dto/PersonalInfoDetectionResponse.java, src/main/java/.../GlobalExceptionHandler.java
새 DTO PersonalInfoDetectionResponse를 추가하고, PersonalInfoDetectedException 처리 응답 타입을 PersonalInfoDetectionResponse로 변경했습니다.
InterviewSubmissionService에서 개인정보 검출 제거
src/main/java/.../InterviewSubmissionService.java
제출 흐름에서 개인정보 감지 의존성·검증·관련 유틸(문자열 조합)과 실패 처리 블록을 제거하여 저장 후 성공 감사로그 및 정상 응답 반환으로 단순화했습니다.
ProjectSession 생성 검증 추가
src/main/java/.../projectSession/ProjectSessionController.java, src/main/java/.../projectSession/ProjectSessionService.java, src/test/java/.../projectSession/ProjectSessionServiceTest.java
프로젝트 세션 생성의 400 응답 스키마에 PersonalInfoDetectionResponse를 추가하고, 서비스에 PersonalInfoDetectionService를 주입해 코드 콘텐츠를 검사하고 경고가 있으면 감사 실패 기록 후 PersonalInfoDetectedException을 던집니다. 단위 테스트를 추가했습니다.
InterviewSubmissionServiceTest 조정
src/test/java/.../InterviewSubmissionServiceTest.java
개인정보 포함 제출 테스트가 예외 기대에서 정상 응답 검증으로 변경되고, 테스트 생성자 인자와 어서션이 이에 맞춰 수정되었습니다.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • TroubleLog/TroubleLog-server#15: 관련된 saveAnswer/AnswerResponse 흐름 변경을 포함한 PR로, 본 PR의 improvement 정규화와 연관됩니다.
  • TroubleLog/TroubleLog-server#8: AnswerFeedbackResult에 improvement 필드가 다뤄진 PR로, improvement 생성·파싱 규칙과 관련이 있습니다.

Poem

🐰
개선 없는 문장에 당근을 꽂아
빈 칸엔 따뜻한 기본 문장을 남기네.
검출의 바람은 한곳으로 흩어지고,
서비스는 조용히 응답을 돌려주네.
축하의 당근, 오늘도 한 입!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.74% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 'improve 답변 Null로 반환하는 이슈 해결'로 InterviewService에서 AI 피드백의 improvement 값이 null일 때 기본값으로 치환하는 핵심 변경을 정확히 반영합니다.
Linked Issues check ✅ Passed PR은 linked issue #17의 'API 테스트 후 발견된 버그 수정' 목표를 충족합니다. improvement null 처리, Swagger 문서 개선, 개인정보 감지 로직 정리, 테스트 추가 등이 모두 구현되었습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 API 테스트 후 발견된 버그 수정 범위 내에 있습니다. improvement null 처리, Swagger 설명 업데이트, 개인정보 감지 로직 정리, 테스트 추가가 모두 명시된 목표와 관련이 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/#17-fix

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/test/java/com/example/trouble_log/domain/interview/service/InterviewServiceTest.java`:
- Around line 89-108: Add a sibling test to cover the blank-string case: in
InterviewServiceTest create an AnswerFeedbackResult whose improvement is a
whitespace string (e.g., "   "), stub promptService.evaluateAnswer(...) to
return it, prepare the same existingAnswer and AnswerRequest, call
interviewService.saveAnswer(1L, 1L, request) and assert that
response.getImprovement() equals the same default improvement string used in
saveAnswerReturnsDefaultImprovementWhenAiImprovementIsNull; this ensures the
service logic that checks isBlank() (via promptService.evaluateAnswer,
AnswerFeedbackResult, and interviewService.saveAnswer) is exercised for blank
input as well.
🪄 Autofix (Beta)

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.yml

Review profile: CHILL

Plan: Pro

Run ID: 21e5b15a-6eaf-42da-aa73-367735e3900e

📥 Commits

Reviewing files that changed from the base of the PR and between be3a8b9 and 5f8b344.

📒 Files selected for processing (2)
  • src/main/java/com/example/trouble_log/domain/interview/service/InterviewService.java
  • src/test/java/com/example/trouble_log/domain/interview/service/InterviewServiceTest.java

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/test/java/com/example/trouble_log/domain/interview/service/InterviewSubmissionServiceTest.java (1)

49-71: 💤 Low value

테스트 완성도를 위해 추가 assertion 고려

다른 테스트(submitReturnsReadyWhenAllAnswersDoNotContainPersonalInfo, lines 93-96)에서는 blockedReason과 warnings도 함께 검증하고 있습니다. 일관성을 위해 이 테스트에도 동일한 assertion을 추가하면 응답 객체 전체가 예상대로 반환되는지 명확히 확인할 수 있습니다.

♻️ 제안하는 수정
         InterviewSubmitResponse response = interviewSubmissionService.submit(1L, request);

         assertThat(response.getSubmitted()).isTrue();
         assertThat(response.getReportGenerationReady()).isTrue();
+        assertThat(response.getBlockedReason()).isNull();
+        assertThat(response.getWarnings()).isEmpty();
     }
🤖 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/test/java/com/example/trouble_log/domain/interview/service/InterviewSubmissionServiceTest.java`
around lines 49 - 71, Add assertions to verify the response's blockedReason and
warnings for completeness: after calling interviewSubmissionService.submit(...)
assert that response.getBlockedReason() is null (no blocking reason) and that
response.getWarnings() contains at least one warning about personal info (e.g.,
isNotEmpty()/contains relevant message). This change should be added inside
submitDoesNotBlockWhenAnswerContainsPersonalInfo() alongside the existing checks
of getSubmitted() and getReportGenerationReady().
🤖 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/test/java/com/example/trouble_log/domain/projectSession/service/ProjectSessionServiceTest.java`:
- Around line 41-53: Add a positive success test to ProjectSessionServiceTest
that verifies create(request) succeeds when code content contains no personal
info: mock a Member (mockMember) and stub memberRepository.findById(1L) to
return it, mock a ProjectSession (mockSession) and stub
projectSessionRepository.save(...) to return mockSession, call
projectSessionService.create(...) with a clean ProjectSessionRequest (e.g.,
greeting code), assert the returned ProjectSessionResponse.getSessionId() equals
mockSession.getId(), and verify projectSessionRepository.save(...) was invoked;
use the same symbols shown (projectSessionService.create, memberRepository,
projectSessionRepository, ProjectSessionRequest, ProjectSessionResponse) and
avoid triggering PersonalInfoDetectedException.

---

Nitpick comments:
In
`@src/test/java/com/example/trouble_log/domain/interview/service/InterviewSubmissionServiceTest.java`:
- Around line 49-71: Add assertions to verify the response's blockedReason and
warnings for completeness: after calling interviewSubmissionService.submit(...)
assert that response.getBlockedReason() is null (no blocking reason) and that
response.getWarnings() contains at least one warning about personal info (e.g.,
isNotEmpty()/contains relevant message). This change should be added inside
submitDoesNotBlockWhenAnswerContainsPersonalInfo() alongside the existing checks
of getSubmitted() and getReportGenerationReady().
🪄 Autofix (Beta)

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.yml

Review profile: CHILL

Plan: Pro

Run ID: 27463613-aa35-4c09-951c-6e141569d5c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5f8b344 and 1023149.

📒 Files selected for processing (9)
  • src/main/java/com/example/trouble_log/domain/interview/controller/InterviewSubmissionController.java
  • src/main/java/com/example/trouble_log/domain/interview/dto/PersonalInfoDetectionResponse.java
  • src/main/java/com/example/trouble_log/domain/interview/service/InterviewSubmissionService.java
  • src/main/java/com/example/trouble_log/domain/projectSession/controller/ProjectSessionController.java
  • src/main/java/com/example/trouble_log/domain/projectSession/service/ProjectSessionService.java
  • src/main/java/com/example/trouble_log/global/exception/GlobalExceptionHandler.java
  • src/test/java/com/example/trouble_log/domain/interview/service/InterviewServiceTest.java
  • src/test/java/com/example/trouble_log/domain/interview/service/InterviewSubmissionServiceTest.java
  • src/test/java/com/example/trouble_log/domain/projectSession/service/ProjectSessionServiceTest.java
✅ Files skipped from review due to trivial changes (2)
  • src/main/java/com/example/trouble_log/domain/interview/controller/InterviewSubmissionController.java
  • src/main/java/com/example/trouble_log/domain/projectSession/controller/ProjectSessionController.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/com/example/trouble_log/domain/interview/service/InterviewServiceTest.java

개인정보 없는 케이스 사례 추가
@hgeniee
hgeniee merged commit 3165f86 into main Jun 6, 2026
2 checks 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 테스트 후 수정사항

1 participant