Skip to content

Chore: 전역 ValidationPipe 및 예외 응답 처리 표준화 (#73)#87

Merged
IISweetHeartII merged 4 commits intodevfrom
task/validation-pipe-#73
Feb 12, 2026
Merged

Chore: 전역 ValidationPipe 및 예외 응답 처리 표준화 (#73)#87
IISweetHeartII merged 4 commits intodevfrom
task/validation-pipe-#73

Conversation

@IISweetHeartII
Copy link
Contributor

Summary

전역 ValidationPipe를 활성화하고 Validation 실패 응답을 GlobalExceptionFilter 공통 포맷과 정합되게 표준화했습니다.

Changes

  • main.ts에 전역 ValidationPipe 적용 (whitelist, forbidNonWhitelisted, transform)
  • GlobalExceptionFilter에 Validation 에러 분기(COMMON400) 처리 추가
  • 주요 구현 완료 엔드포인트에 ParseIntPipe 적용해 숫자 파라미터 검증 표준화
  • docs/development/ERROR_HANDLING.md에 ValidationPipe 운영 규칙 및 응답 예시 문서화

Type of Change

  • Bug fix (기존 기능을 수정하는 변경)
  • New feature (새로운 기능 추가)
  • Breaking change (기존 기능에 영향을 주는 변경)
  • Refactoring (기능 변경 없이 코드 개선)
  • Documentation (문서 변경)
  • Chore (빌드, 설정 등)

Target Environment

  • Dev (dev)
  • Prod (main)

Related Issues

Testing

  • Postman/Swagger로 API 호출 확인
  • 단위 테스트 통과
  • E2E 테스트 통과

실행 결과:

  • pnpm run lint: 통과
  • pnpm run build: 통과 (TSC 0 issues)
  • pnpm exec jest --passWithNoTests: No tests found, code 0

Checklist

  • 코드 컨벤션을 준수했습니다 (docs/development/CODE_STYLE.md)
  • Git 컨벤션을 준수했습니다 (docs/development/GIT_CONVENTIONS.md)
  • 네이밍 컨벤션을 준수했습니다 (docs/development/NAMING_CONVENTIONS.md)
  • 로컬에서 빌드가 성공합니다 (pnpm run build)
  • 로컬에서 린트가 통과합니다 (pnpm run lint)
  • (API 변경 시) Swagger 문서가 업데이트되었습니다
  • (필요 시) 테스트 코드를 작성했습니다

Screenshots (Optional)

N/A

Additional Notes

  • 영향 범위를 줄이기 위해 구현 완료된 엔드포인트 중심으로 ParseIntPipe를 적용했습니다.
  • Validation 실패 응답은 기존 CommonResponse.fail() 포맷으로 일관 처리됩니다.

@gemini-code-assist
Copy link

Summary of Changes

Hello @IISweetHeartII, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 전역 ValidationPipe를 활성화하고 유효성 검사 실패 응답을 GlobalExceptionFilter의 공통 에러 응답 형식에 맞춰 표준화하여 API의 견고성과 일관성을 향상시키는 것을 목표로 합니다. 이를 통해 클라이언트에게 보다 예측 가능한 에러 응답을 제공하고, 개발자가 유효성 검사 로직을 더 쉽게 관리할 수 있도록 지원합니다.

Highlights

  • 전역 ValidationPipe 활성화: main.ts에 whitelist, forbidNonWhitelisted, transform 옵션을 사용하여 전역 ValidationPipe를 적용하여 요청 유효성 검사를 강화했습니다.
  • 유효성 검사 실패 응답 표준화: GlobalExceptionFilter에 ValidationPipe 및 ParseIntPipe에서 발생하는 유효성 검사 오류를 COMMON400 형식으로 처리하도록 로직을 추가하여 응답 형식을 통일했습니다.
  • 숫자 파라미터 검증 표준화: 주요 엔드포인트의 숫자 파라미터에 ParseIntPipe를 적용하여 파라미터 유효성 검사를 표준화했습니다.
  • 에러 처리 문서 업데이트: docs/development/ERROR_HANDLING.md에 ValidationPipe 운영 규칙 및 유효성 검사 실패 응답 예시를 문서화했습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/common/filters/global-exception.filter.ts
    • BadRequestException을 임포트했습니다.
    • 유효성 검사 오류 응답을 위한 ValidationErrorResponse 인터페이스를 추가했습니다.
    • handleException 메서드에 ValidationPipe 및 ParseIntPipe에서 발생하는 BadRequestException을 감지하고 COMMON400 에러 코드로 처리하는 로직을 추가했습니다.
    • 유효성 검사 오류를 식별하는 헬퍼 메서드 isValidationError를 구현했습니다.
  • src/main.ts
    • ValidationPipe를 임포트했습니다.
    • app.useGlobalPipes를 사용하여 whitelist, forbidNonWhitelisted, transform 옵션이 적용된 전역 ValidationPipe를 등록했습니다.
  • src/modules/experience/presentation/experience.controller.ts
    • ParseIntPipe를 임포트했습니다.
    • getExperience 메서드의 experienceId 파라미터에 ParseIntPipe를 적용했습니다.
  • src/modules/insight/presentation/insight.controller.ts
    • ParseIntPipe를 임포트했습니다.
    • updateLog 및 deleteLog 메서드의 insightId 파라미터에 ParseIntPipe를 적용했습니다.
  • src/modules/portfolio-correction/presentation/external-portfolio.controller.ts
    • ParseIntPipe를 임포트했습니다.
    • getExternalPortfolios 메서드의 correctionId 쿼리 파라미터에 ParseIntPipe를 적용했습니다.
  • src/modules/portfolio-correction/presentation/portfolio-correction.controller.ts
    • ParseIntPipe를 임포트했습니다.
    • getCorrectionStatus 및 getCorrection 메서드의 correctionId 파라미터에 ParseIntPipe를 적용했습니다.
Ignored Files
  • Ignored by pattern: *.md (1)
    • docs/development/ERROR_HANDLING.md
Activity
  • 현재까지 이 Pull Request에 대한 사람의 활동(댓글, 리뷰 등)은 없습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR introduces a global ValidationPipe to standardize validation failure responses, which is a good step towards improving data validation. However, a medium-severity Reflected XSS vulnerability has been identified in the new error handling logic, where validation error messages are directly reflected in the JSON response. Additionally, the approach of adding separate logic to GlobalExceptionFilter for NestJS built-in exceptions increases filter complexity and violates the style guide, which recommends using BusinessException instead. It's crucial to address the XSS vulnerability by sanitizing error messages and refactor the exception handling to use BusinessException for better maintainability and adherence to style guidelines.

@IISweetHeartII IISweetHeartII self-assigned this Feb 12, 2026
@IISweetHeartII IISweetHeartII added 📚 docs Improvements or additions to documentation ✨ feature New feature or request 🧹 chore setting 덕환 labels Feb 12, 2026
@IISweetHeartII IISweetHeartII changed the title Task: 전역 ValidationPipe 및 예외 응답 처리 표준화 (#73) Chore: 전역 ValidationPipe 및 예외 응답 처리 표준화 (#73) Feb 12, 2026
@IISweetHeartII IISweetHeartII merged commit 30a6615 into dev Feb 12, 2026
2 checks passed
@IISweetHeartII IISweetHeartII deleted the task/validation-pipe-#73 branch February 12, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 docs Improvements or additions to documentation 🧹 chore setting ✨ feature New feature or request 덕환

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] 전역 ValidationPipe 및 예외 응답 처리 표준화

1 participant