Skip to content

fix: ReviewDetailV1 NPE 위험 수정#402

Open
pooreumjung wants to merge 1 commit into
developfrom
fix/#401-review-detail-v1-npe
Open

fix: ReviewDetailV1 NPE 위험 수정#402
pooreumjung wants to merge 1 commit into
developfrom
fix/#401-review-detail-v1-npe

Conversation

@pooreumjung

Copy link
Copy Markdown
Member

#️⃣ Issue Number

📝 요약(Summary)

  • ReviewDetailV1.from()review.getRatings()가 null일 때(V2 경로로 생성되어 rating 필드만 채워진 리뷰) getMainRating() 호출에서 NPE가 발생하던 문제를 수정했습니다.
  • V2 쪽 ReviewDetail.from()에 이미 있던 rating != null ? rating : ratings.getMainRating() null-safe 패턴을 V1에도 동일하게 적용했습니다. ratings가 null인 경우 amountRating/tasteRating은 V2 리뷰에 애초에 값이 없으므로 그대로 null을 반환합니다.

💬 공유사항 to 리뷰어

  • V1과 V2 리뷰 조회 응답이 동시에 존재하는 메뉴에서 실제로 크래시 없이 조회되는지 확인 부탁드립니다.
  • 별도 통합 테스트는 추가하지 않았습니다. Review.ratings/Review.rating이 서로 배타적으로 채워지는 케이스에 대한 테스트가 없다면 이번 기회에 추가하는 것도 고려해볼 만합니다.

✅ PR Checklist

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • 커밋 메시지 컨벤션에 맞게 작성했습니다.
  • 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@pooreumjung pooreumjung added the fix 고치기 label Jul 9, 2026
@pooreumjung pooreumjung self-assigned this Jul 9, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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은 V2 리뷰 데이터 구조와 호환되는 리뷰 조회 시 발생하는 NPE 문제를 해결합니다. Ratings 객체가 없는 경우에도 V1 응답 모델이 정상적으로 데이터를 처리할 수 있도록 null 체크 로직을 추가하여 시스템 안정성을 높였습니다.

Highlights

  • NPE 방지 로직 추가: ReviewDetailV1.from() 메서드에서 review.getRatings()가 null일 경우 발생하는 NullPointerException을 방지하기 위해 null-safe 패턴을 적용했습니다.
  • 데이터 매핑 방식 개선: Ratings 객체의 존재 여부에 따라 mainRating, amountRating, tasteRating 값을 안전하게 할당하도록 로직을 수정했습니다.
New Features

🧠 You can now enable Memory (public preview) 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.

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 the 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 counterproductive. 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.


리뷰의 별점 확인하려다, 널(null)을 만나 멈춰버린 코드. 안전하게 확인하고, 다시 흐르는 서비스의 길.

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.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

이번 풀 리퀘스트는 ReviewDetailV1 DTO에서 ratings 객체가 null일 때 발생할 수 있는 NullPointerException을 방지하기 위해 null 검사를 추가하고, 기본값으로 review.getRating()을 사용하도록 수정하였습니다. 이에 대해 ratingsreview.getRating()이 모두 null인 경우 mainRating이 null이 될 수 있으므로 Objects.requireNonNull 등을 사용해 null 검증을 하거나 기본값을 제공하라는 피드백이 있었습니다.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +57 to +60
Ratings ratings = review.getRatings();
Integer mainRating = (ratings != null) ? ratings.getMainRating() : review.getRating();
Integer amountRating = (ratings != null) ? ratings.getAmountRating() : null;
Integer tasteRating = (ratings != null) ? ratings.getTasteRating() : null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

[pooreumjung, 2026-07-09] ratings와 review.getRating()이 모두 null인 경우 mainRating이 null이 될 수 있으므로, Objects.requireNonNull 등을 사용하여 null 검증을 하거나 기본값을 제공하는 것이 안전합니다.

Suggested change
Ratings ratings = review.getRatings();
Integer mainRating = (ratings != null) ? ratings.getMainRating() : review.getRating();
Integer amountRating = (ratings != null) ? ratings.getAmountRating() : null;
Integer tasteRating = (ratings != null) ? ratings.getTasteRating() : null;
Ratings ratings = review.getRatings();
Integer mainRating = (ratings != null) ? ratings.getMainRating() : java.util.Objects.requireNonNull(review.getRating(), "Rating must not be null");
Integer amountRating = (ratings != null) ? ratings.getAmountRating() : null;
Integer tasteRating = (ratings != null) ? ratings.getTasteRating() : null;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix 고치기

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: ReviewDetailV1 NPE 위험 (V2 리뷰의 ratings null)

1 participant