Skip to content

refactor: throw new Error 도메인 오류 정리 (P1-2)#116

Merged
chanwoo7 merged 1 commit into
developfrom
refactor/throw-error-cleanup
May 27, 2026
Merged

refactor: throw new Error 도메인 오류 정리 (P1-2)#116
chanwoo7 merged 1 commit into
developfrom
refactor/throw-error-cleanup

Conversation

@chanwoo7
Copy link
Copy Markdown
Member

@chanwoo7 chanwoo7 commented May 27, 2026

Summary

도메인 입력 오류 (request path) 를 throw new Error 대신 HttpException 으로 변환한다.
boot-time fail-fast (config / JWT_ACCESS_SECRET 누락 등) 는 운영 의도(500) 와 일치하므로 그대로 유지.

Scope

  • 변경 1: 동작 차이 있음 (FE 협의 #6 refactor soft delete #3 대상)
    • src/features/auth/types/oidc-provider.type.ts
    • 잘못된 provider 슬러그 → throw new ErrorBadRequestException
    • 호출 컨텍스트: auth.controller.ts:97 OIDC 콜백, oidc-login.service.ts:51,75
    • Before: 500 Internal Server Error
    • After: 400 Bad Request (Unsupported OIDC provider: <raw>)
  • 변경 2: 동작 차이 없음 (스타일 정리)
    • src/common/utils/id-parser.ts
    • src/global/auth/parse-account-id.ts
    • 같은 함수 내 try/catch 제어흐름용 throw new Error('empty'/'negative') 제거
    • BadRequestException 직접 throw 로 단순화. 외부 응답은 이미 400 으로 동일.
  • 변경 3: 유지 (boot-time fail-fast)
    • src/config/{oidc,auth,docs,s3,database}.config.ts
    • src/common/helpers/config.helper.ts (mustGetEnv)
    • src/global/auth/auth-global.module.ts (JwtModule factory)
    • src/features/auth/strategies/jwt-bearer.strategy.ts (생성자)
    • 위는 모두 부팅 시점에 process exit 의도. CLAUDE.md "운영 환경에서 JWT 시크릿 누락 시 서버가 뜨면 안 됨 (fail-fast)" 와 일치.

FE 협의 #3 — 액션 요청

대상 경로: /auth/oidc/<provider>/... (구체적으로 invalid provider slug 가 들어온 경우)

Before After
HTTP status 500 400
body Internal server error { statusCode: 400, message: "Unsupported OIDC provider: <raw>" }
  • 위 경로에 대한 500 retry 로직이 있다면 제거 (이제 4xx 로 변환됨, retry 무의미)
  • 다른 OIDC 엔드포인트 동작은 동일

Impact

  • FE: 있음 (정상화) — 협의 #6 refactor soft delete #3 안내 위 표
  • DB: 변경 없음
  • Coverage: pre-push validate gate 통과 (전체 1174 테스트)

Test plan

  • oidc-provider.type.spec — BadRequestException assertion 추가
  • id-parser.spec / parse-account-id.spec — 기존 BadRequestException assertion 그대로 통과
  • pre-push gate (yarn validate) 로컬 통과
  • CI 통과 확인
  • FE 에 협의 #6 refactor soft delete #3 안내 (머지 직전)

도메인 입력 오류를 throw new Error 대신 HttpException 으로 변환.
boot-time fail-fast(config/JWT_ACCESS_SECRET 누락 등)는 그대로 유지.

- oidc-provider.type.ts: throw new Error → BadRequestException (FE 응답 500→400)
  - 호출 컨텍스트: HTTP request path (auth.controller 콜백 + oidc-login.service)
  - 협의 #3 대상 — 500 retry 로직이 있다면 제거 필요
- id-parser.ts / parse-account-id.ts: 같은 함수 내 try/catch 제어흐름용
  throw new Error 'empty'/'negative' 제거. BadRequestException 직접 throw 로 단순화.
  외부 동작 동일 (이미 catch 에서 BadRequestException 으로 변환됨).
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d8ee202e-f2c0-4ba3-823f-36e921a7332a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/throw-error-cleanup

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 97.31% 3511/3608
🟢 Branches 93.51% 1123/1201
🟢 Functions 93.6% 643/687
🟢 Lines 97.54% 3213/3294

Test suite run success

1174 tests passing in 142 suites.

Report generated by 🧪jest coverage report action from 31634e7

@chanwoo7 chanwoo7 merged commit 82ee3c6 into develop May 27, 2026
10 checks passed
@chanwoo7 chanwoo7 deleted the refactor/throw-error-cleanup branch May 27, 2026 19:40
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.

1 participant