Skip to content

Conversation

@RCNR
Copy link
Contributor

@RCNR RCNR commented Aug 13, 2025

📍 PR 타입 (하나 이상 선택)

  • 기능 추가
  • 버그 수정
  • 의존성, 환경 변수, 빌드 관련 코드 업데이트
  • 기타 사소한 수정

🏷️ 관련 이슈

Close #82

📌 개요

  • 게시글 목록 조회에서 사용하는 유효성 검사 어노테이션인 @max 사용 시 validator 의존관계 설정 추가

🔁 변경 사항

📸 스크린샷

✅ 체크리스트

  • 코드가 정상적으로 동작하는지 확인
  • PR에 적절한 라벨을 선택
  • 관련 테스트 코드 작성
  • 문서(README, Swagger 등) 업데이트

💡 추가 사항 (리뷰어가 참고해야 할 것)

Summary by CodeRabbit

  • New Features
    • Enables built-in validation across requests and domain models, supporting constraint annotations and automated error responses for APIs and forms, reduces manual checks, standardizes error formats, and supports localization-ready messages.
  • Chores
    • Updated build dependencies to include validation components; no other dependency or build logic changes.

@RCNR RCNR self-assigned this Aug 13, 2025
@RCNR RCNR added the bug Something isn't working label Aug 13, 2025
@RCNR RCNR linked an issue Aug 13, 2025 that may be closed by this pull request
1 task
@coderabbitai
Copy link

coderabbitai bot commented Aug 13, 2025

Walkthrough

Added Spring Boot validation dependency to build.gradle to enable validation annotations.

Changes

Cohort / File(s) Summary
Build dependency updates
build.gradle
Added implementation dependency: org.springframework.boot:spring-boot-starter-validation

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Assessment against linked issues

Objective Addressed Explanation
Add validation dependency in build.gradle to resolve Validator errors (#82)

Assessment against linked issues: Out-of-scope changes

(No out-of-scope changes identified.)

Poem

I twitch my ears at the build’s new shine,
A starter hops in—validation time!
Max won’t grumble, handlers won’t cry,
Our posts can leap and safely fly.
Thump-thump! The pipeline hums in tune—
A rabbit’s fix, deployed by noon. 🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/#82-getPosts-api-validator-global-error

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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 933f471 and fecca8c.

📒 Files selected for processing (1)
  • build.gradle (1 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
🔇 Additional comments (1)
build.gradle (1)

33-33: Correct dependency added to enable Bean Validation in Spring Boot 3.x

Adding spring-boot-starter-validation is the right fix for “No target Validator set”. This pulls in Hibernate Validator and auto-configures a Validator, enabling annotations like @max to work.

implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'org.springframework.boot:spring-boot-starter-validation'
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Validate controller setup for @max on @RequestParam/@PathVariable

Starter alone wires the Validator, but simple type constraints require @validated on the controller (or method) for MVC/WebFlux binding. Also, if you rely on method-level validation for services, add @EnableMethodValidation on a configuration class.

Run the following to locate usages and verify annotations:

If any controllers using @RequestParam/@PathVariable constraints lack @validated, I can propose a small patch.


🏁 Script executed:

#!/bin/bash
# Show all @Max usages with context
rg -n -A 5 -B 5 '@Max\s*\('

echo
echo "Controllers annotated with @Validated:"
rg -n '@(org\.springframework\.validation\.annotation\.)?Validated'

echo
echo "Presence of @EnableMethodValidation (optional, for method-level validation):"
rg -n '@(org\.springframework\.validation\.annotation\.)?EnableMethodValidation'

Length of output: 1862


Annotate controllers with @validated to enforce @max constraints

The PostController#getPostList method applies @Max(30) to a @RequestParam but the controller isn’t annotated with Spring’s method‐validation support, so that constraint won’t be enforced at runtime. Add @Validated on the class (or method) level. If you also rely on service‐layer method validation, enable it via @EnableMethodValidation in a configuration class.

• File: src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
– Add @Validated to the controller class.
• (Optional) File: any @Configuration class
– Add @EnableMethodValidation to activate service‐layer method validation.

Suggested diff:

--- a/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
+++ b/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
@@
- @RestController
+ @RestController
+ @Validated
  @RequestMapping("/boards/{boardType}/posts")
  public class PostController {
      …
📝 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.

Suggested change
implementation 'org.springframework.boot:spring-boot-starter-validation'
--- a/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
+++ b/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
@@
- @RestController
+ @RestController
+ @Validated
@RequestMapping("/boards/{boardType}/posts")
public class PostController {
🤖 Prompt for AI Agents
In src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
around the class declaration, the controller is missing Spring’s @Validated so
method-level javax validation (e.g. @Max on @RequestParam in getPostList) won’t
be enforced; add the @Validated annotation to the controller class and import
org.springframework.validation.annotation.Validated; additionally, if you want
service-layer method validation enabled, add @EnableMethodValidation to a
@Configuration class (and import
org.springframework.validation.annotation.EnableMethodValidation) to activate
method validation across beans.

@RCNR RCNR merged commit 9372a9e into dev Aug 13, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fix] : 게시글 목록 조회 API Validator 오류

2 participants