Skip to content

Conversation

@bbbang105
Copy link
Member

@bbbang105 bbbang105 commented Nov 25, 2025

✅ PR 유형

어떤 변경 사항이 있었나요?

  • 새로운 기능 추가
  • 버그 수정
  • 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경)
  • 코드 리팩토링
  • 주석 추가 및 수정
  • 문서 수정
  • 빌드 부분 혹은 패키지 매니저 수정
  • 파일 혹은 폴더명 수정
  • 파일 혹은 폴더 삭제

🚀 작업 내용

이번 PR에서 작업한 내용을 구체적으로 설명해주세요. (이미지 첨부 가능)

  • QA 중 나왔던 의견인 예외 처리 추가를 진행하였습니다.
  • 200 OK 응답이 왔지만, 테이블이 비어있는 경우 -> 응답 자체는 동일하지만 xml에서 status에 차이가 있는 점을 활용하여 분기 처리할 수 있었습니다.
  • status가 -2면 private / status가 1이면 public 입니다.
  • 매직 넘버를 지양하기 위해서 둘을 상수화하였습니다.

📝️ 관련 이슈

본인이 작업한 내용이 어떤 Issue와 관련이 있는지 작성해주세요.


💬 기타 사항 or 추가 코멘트

남기고 싶은 말, 참고 블로그 등이 있다면 기록해주세요.

1. '전체 공개'가 아닌 경우: status="-2"

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<response>


<table identifier="de9YHaTAnl47JtxH0muz" semester="1" status="-2" year="2024"/>


</response>

2. 전체 공개이지만, 등록된 시간표가 없는 경우: status="1"

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<response>


<table identifier="DSDsEMwVCQWl9UiBZpZm" semester="2" status="1" year="2024"/>


</response>

Summary by CodeRabbit

  • 버그 수정

    • 에브리타임 시간표 조회 실패 시 권한(비공개)과 등록된 수업 없음 상황을 명확히 구분하도록 개선
    • 관련 에러 코드/메시지 표현을 명확히 정리
  • 신규 에러

    • FIXED-005 추가: 등록된 수업 없음(에브리타임)
  • 테스트

    • 시간표 비공개 및 수업 미등록 시나리오를 각각 검증하는 테스트 케이스 추가 및 실패 문구 갱신

✏️ Tip: You can customize this high-level summary in your review settings.

@bbbang105 bbbang105 added 🚀 feat 새로운 기능 추가 / 일부 코드 추가 / 일부 코드 수정 (리팩토링과 구분) / 디자인 요소 수정 😵‍💫 sangho 상호 PR labels Nov 25, 2025
@bbbang105 bbbang105 self-assigned this Nov 25, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

Walkthrough

XML의 status 속성을 정규식으로 추출해 공개/비공개·빈 수업·파싱 오류를 구분하도록 FixedScheduleService가 분기 로직을 추가하고, FixedErrorStatus의 enum 상수를 재구성하며 관련 테스트를 확충했습니다.

Changes

Cohort / File(s) 변경 요약
에러 상태 정의
src/main/java/side/onetime/exception/status/FixedErrorStatus.java
_NOT_FOUND_EVERYTIME_TIMETABLE 이름을 _EVERYTIME_TIMETABLE_NOT_PUBLIC로 변경(기존 FIXED-002 유지); 새로운 _NOT_FOUND_EVERYTIME_TIMETABLE 추가(FIXED-005); 중복 HttpStatus import 제거
서비스 로직 개선
src/main/java/side/onetime/service/FixedScheduleService.java
XML에서 status 값을 추출하는 정규식 기반 extractStatusFromXml(String) 추가; EVERYTIME_PRIVATE_STATUS, EVERYTIME_PUBLIC_STATUS, STATUS_PATTERN 상수 추가; status에 따라 예외 분기 추가(비공개 → EVERYTIME_TIMETABLE_NOT_PUBLIC, 공개+빈 → NOT_FOUND_EVERYTIME_TIMETABLE, 추출/파싱 실패 → EVERYTIME_TIMETABLE_PARSE_ERROR)
테스트 케이스 확충
src/test/java/side/onetime/fixed/FixedControllerTest.java
기존 실패 테스트의 기대 예외/메시지를 EVERYTIME_TIMETABLE_NOT_PUBLIC으로 조정; 신규 테스트 getEverytimeTimetable_Fail_Empty 추가하여 공개이지만 등록된 수업이 없을 때 404 FIXED-005 검증

Sequence Diagram(s)

sequenceDiagram
    participant Client as 클라이언트
    participant Controller as 컨트롤러
    participant Service as FixedScheduleService
    participant XML as 원본 XML

    Client->>Controller: 에브리타임 시간표 조회 요청
    Controller->>Service: 시간표 조회 요청 전달
    Service->>XML: XML 컨텐츠 수신/읽기
    XML-->>Service: XML 반환

    alt XML 존재 및 읽기 성공
        Service->>Service: extractStatusFromXml(xml)
        alt status == EVERYTIME_PRIVATE_STATUS (-2)
            Service-->>Controller: EVERYTIME_TIMETABLE_NOT_PUBLIC 예외 발생
            Controller-->>Client: 404 FIXED-002
        else status == EVERYTIME_PUBLIC_STATUS (1) && 수업 없음
            Service-->>Controller: NOT_FOUND_EVERYTIME_TIMETABLE 예외 발생
            Controller-->>Client: 404 FIXED-005
        else status == EVERYTIME_PUBLIC_STATUS (1) && 수업 있음
            Service-->>Controller: 변환된 시간표 반환
            Controller-->>Client: 200 OK
        end
    else XML 파싱/추출 실패
        Service-->>Controller: EVERYTIME_TIMETABLE_PARSE_ERROR 예외 발생
        Controller-->>Client: 파싱 오류 응답
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20분

  • 주의할 항목:
    • extractStatusFromXml()의 정규식 경계조건 및 예외 처리
    • FixedErrorStatus enum명 변경이 전역 참조에 일관되게 반영되었는지
    • 테스트 getEverytimeTimetable_Fail_Empty의 모킹/응답 시나리오 정확성
    • 파싱 실패 시 던지는 예외와 컨트롤러의 HTTP 매핑 일관성

🐰 XML 숲을 킁킁거려
공개인지 비공개인지 냄새 맡아
빈 강의실이면 조용히 알려주고
파싱은 조심히, 테스트는 깡총깡총 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경사항의 핵심을 명확하게 설명하고 있으며, 전체 공개이지만 등록된 수업이 없는 경우에 대한 예외 처리 추가라는 주요 목표를 정확히 반영하고 있습니다.
Description check ✅ Passed PR 설명이 템플릿의 주요 섹션(PR 유형, 작업 내용, 관련 이슈, 기타 사항)을 포함하고 있으며, 특히 작업 내용에서 구체적인 예시와 구현 상세가 잘 설명되어 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/add-exception

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9eb52c0 and 280ccaf.

📒 Files selected for processing (1)
  • src/main/java/side/onetime/service/FixedScheduleService.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/side/onetime/service/FixedScheduleService.java

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.

❤️ Share

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

@bbbang105 bbbang105 changed the title [feat] : '전체 공개이지만, 등록된 시간이 없는 경우' 예외 처리를 추가한다 [feat] : '전체 공개이지만, 등록된 수업이 없는 경우' 예외 처리를 추가한다 Nov 25, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9dcfb5 and eb12f7c.

📒 Files selected for processing (3)
  • src/main/java/side/onetime/exception/status/FixedErrorStatus.java (1 hunks)
  • src/main/java/side/onetime/service/FixedScheduleService.java (3 hunks)
  • src/test/java/side/onetime/fixed/FixedControllerTest.java (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/side/onetime/service/FixedScheduleService.java (3)
src/main/java/side/onetime/exception/status/ScheduleErrorStatus.java (2)
  • Override (21-28)
  • Getter (9-39)
src/main/java/side/onetime/global/common/status/ErrorStatus.java (1)
  • Override (36-44)
src/main/java/side/onetime/exception/status/EventErrorStatus.java (1)
  • Override (32-40)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build and Push to ECR
🔇 Additional comments (5)
src/test/java/side/onetime/fixed/FixedControllerTest.java (2)

216-222: LGTM! 테스트 케이스가 리팩토링된 에러 처리와 잘 정렬되어 있습니다.

DisplayName이 실패 사유를 명확히 표현하고 있으며, 예외 타입이 _EVERYTIME_TIMETABLE_NOT_PUBLIC으로 변경되어 의미가 더 명확해졌습니다.


246-275: LGTM! 빈 시간표 시나리오에 대한 테스트 커버리지가 추가되었습니다.

새로운 테스트 케이스가 등록된 수업이 없는 경우를 적절히 검증하고 있으며, 기존 실패 테스트들과 일관된 구조를 유지하고 있습니다.

src/main/java/side/onetime/service/FixedScheduleService.java (2)

9-10: LGTM! 매직 넘버 제거로 코드 가독성이 향상되었습니다.

정규식 관련 import와 상태 코드 상수화가 적절하며, 상수명도 의미를 명확히 전달하고 있습니다.

Also applies to: 41-42


155-175: LGTM! status 추출 로직이 적절하게 구현되었습니다.

정규식 패턴이 음수를 포함한 숫자 형태의 status 값을 정확히 매칭하며, 파싱 실패 시 적절한 예외 처리가 되어 있습니다.

src/main/java/side/onetime/exception/status/FixedErrorStatus.java (1)

3-3: LGTM! 에러 상태 정의가 명확하게 개선되었습니다.

enum 상수명 변경으로 의미가 더 명확해졌고(_EVERYTIME_TIMETABLE_NOT_PUBLIC), 새로운 상수(_NOT_FOUND_EVERYTIME_TIMETABLE, FIXED-005)가 추가되어 빈 시간표 케이스를 적절히 구분하고 있습니다. import 정리도 잘 되었습니다.

Also applies to: 14-14, 17-17

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/java/side/onetime/service/FixedScheduleService.java (1)

158-178: Jsoup을 사용한 일관된 파싱 방식을 고려해보세요.

현재 정규식 기반 접근은 정상적으로 동작하지만, 이 파일의 다른 부분(line 187)에서는 Jsoup을 사용하여 XML을 파싱하고 있습니다. status 속성 추출도 Jsoup으로 통일하면 다음과 같은 이점이 있습니다:

  • XML 파싱 방식의 일관성 확보
  • 속성값 따옴표 유형(single/double)에 대한 견고성 향상 (현재 패턴은 double quote만 매칭)
  • XML 형식 변경에 대한 내구성 향상

Jsoup을 사용한 대체 구현:

 	private int extractStatusFromXml(String xml) {
-		// status="숫자" 패턴을 찾음
-		Pattern pattern = Pattern.compile("status=\"(-?\\d+)\"");
-		Matcher matcher = pattern.matcher(xml);
-
-		if (matcher.find()) {
-			try {
-				return Integer.parseInt(matcher.group(1));
-			} catch (NumberFormatException e) {
-				// 숫자가 아닌 경우 파싱 에러 처리
-				throw new CustomException(FixedErrorStatus._EVERYTIME_TIMETABLE_PARSE_ERROR);
-			}
-		}
-
-		// status 속성을 찾지 못한 경우 파싱 에러 처리
-		throw new CustomException(FixedErrorStatus._EVERYTIME_TIMETABLE_PARSE_ERROR);
+		try {
+			Document doc = Jsoup.parse(xml, "", Parser.xmlParser());
+			Element table = doc.selectFirst("table");
+			if (table == null || !table.hasAttr("status")) {
+				throw new CustomException(FixedErrorStatus._EVERYTIME_TIMETABLE_PARSE_ERROR);
+			}
+			return Integer.parseInt(table.attr("status"));
+		} catch (NumberFormatException e) {
+			throw new CustomException(FixedErrorStatus._EVERYTIME_TIMETABLE_PARSE_ERROR);
+		}
 	}

참고: 현재 정규식 패턴은 작은따옴표(single quote)로 감싼 속성값은 매칭하지 못하지만, Everytime API가 항상 큰따옴표를 사용한다면 문제없습니다.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb12f7c and c37b6a4.

📒 Files selected for processing (1)
  • src/main/java/side/onetime/service/FixedScheduleService.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Deploy to Server
🔇 Additional comments (3)
src/main/java/side/onetime/service/FixedScheduleService.java (3)

9-10: LGTM!

정규식 기반 status 추출을 위한 표준 Java import입니다.


41-42: LGTM!

매직 넘버를 상수화하여 코드 가독성이 향상되었습니다. 네이밍과 접근 제어자 설정도 적절합니다.


140-152: LGTM!

이전 리뷰에서 지적된 예상치 못한 status 값 처리가 올바르게 추가되었습니다. 세 가지 케이스(비공개, 공개이지만 빈 시간표, 파싱 오류)를 명확히 구분하고 있습니다.

Copy link
Member

@anxi01 anxi01 left a comment

Choose a reason for hiding this comment

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

세세한 에러 처리 좋습니다!
고생 하셨습니다~

*/
private int extractStatusFromXml(String xml) {
// status="숫자" 패턴을 찾음
Pattern pattern = Pattern.compile("status=\"(-?\\d+)\"");
Copy link
Member

Choose a reason for hiding this comment

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

compile메소드 내부에서 매 호출마다 Pattern 객체가 생성되기 때문에 상수로 빼면 좋겠습니다!

@anxi01 anxi01 force-pushed the feature/add-exception branch from 9eb52c0 to 280ccaf Compare November 27, 2025 13:53
@anxi01 anxi01 merged commit 652b2b6 into develop Nov 27, 2025
4 checks passed
@anxi01 anxi01 deleted the feature/add-exception branch November 27, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚀 feat 새로운 기능 추가 / 일부 코드 추가 / 일부 코드 수정 (리팩토링과 구분) / 디자인 요소 수정 🔄 refactor 코드 리팩토링 😵‍💫 sangho 상호 PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants