Skip to content

[Fix] collegeId=-1일시 API 요청 안되게 수정#480

Draft
HI-JIN2 wants to merge 1 commit intodevelopfrom
fix/userinfo-invalid-collegeid
Draft

[Fix] collegeId=-1일시 API 요청 안되게 수정#480
HI-JIN2 wants to merge 1 commit intodevelopfrom
fix/userinfo-invalid-collegeid

Conversation

@HI-JIN2
Copy link
Member

@HI-JIN2 HI-JIN2 commented Feb 27, 2026

Summary

  • 운영 환경에서 collegeId=-1이 포함된 상태로 API 요청이 발생하여 VALIDATION_ERROR 예외가 발생함
- 예외 상태코드: VALIDATION_ERROR
- 예외 메시지: 입력값을 확인해주세요.
- 개발환경: prod

요청 정보
- HTTP Method: GET
- URI: /users/lookup/departments
- User ID: 4663
- 로그 내용 (파라미터 정보 포함): userId=4663, deviceType=ANDROID, collegeId=-1
===================

Describe your changes

  • 사용자 정보 입력 플로우에서 collegeId 또는 departmentId의 sentinel 값 -1미선택 상태로 간주하도록 처리
  • collegeId == -1인 경우 GET /users/lookup/departments API를 호출하지 않도록 수정
    → 서버에서 VALIDATION_ERROR 발생 방지

Treat sentinel -1 college/department as unselected to avoid calling /users/lookup/departments with collegeId=-1 (server VALIDATION_ERROR).
@gemini-code-assist
Copy link
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!

This pull request resolves a production issue where an invalid collegeId of -1 was being sent to the backend, leading to a VALIDATION_ERROR. The changes ensure that sentinel -1 values for college and department IDs are correctly interpreted as unselected states within the user information flow, preventing unnecessary and erroneous API calls for department lookups and improving the robustness of the user profile update process.

Highlights

  • Invalid ID Handling: Modified user info flow to treat sentinel -1 college/department IDs as unselected, preventing their use in API calls.
  • API Call Prevention: Implemented logic to skip the GET /users/lookup/departments API call when collegeId is -1.
  • Error Prevention: Addressed a production error by preventing server VALIDATION_ERROR caused by invalid collegeId parameters.

🧠 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
  • app/src/main/java/com/eatssu/android/presentation/mypage/userinfo/UserInfoActivity.kt
    • Modified the condition for checking if a college is selected to also consider collegeId == -1 as an unselected state, prompting the user to select a college.
  • app/src/main/java/com/eatssu/android/presentation/mypage/userinfo/UserInfoViewModel.kt
    • Introduced initialCollege and initialDepartment variables using takeUnless to filter out -1 IDs when initializing user college and department data.
    • Updated the call to userRepository.getTotalDepartments to use initialCollege (which can be null) instead of directly using userInfo.userCollege, thus preventing API calls with -1.
    • Added an explicit check in loadDepartments to return early and update the UI with an empty department list if collegeId is -1, logging a warning.
Activity
  • No specific activity (comments, reviews, progress) was provided in the context.
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.

@HI-JIN2 HI-JIN2 marked this pull request as draft February 27, 2026 04:59
Copy link
Contributor

@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

이 PR은 collegeId-1일 때 발생하는 서버 오류를 방지하기 위해 유효하지 않은 ID로 학과 목록을 조회하는 API 호출을 건너뛰도록 수정합니다. 변경 사항은 UserInfoActivityUserInfoViewModel에 적용되었으며, -1 값을 '선택되지 않음' 상태로 올바르게 처리합니다. 전반적으로 올바른 수정으로 보입니다. 다만, 코드 가독성과 유지보수성 향상을 위해 매직 넘버 -1을 상수로 정의하여 사용하는 것을 제안하는 리뷰 의견을 남겼습니다.

Comment on lines +60 to +61
val initialCollege = userInfo.userCollege.takeUnless { it.collegeId == -1 }
val initialDepartment = userInfo.userDepartment.takeUnless { it.departmentId == -1 }
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

-1이라는 매직 넘버가 코드 여러 곳에서 '선택되지 않음'을 나타내는 값으로 사용되고 있습니다. 코드의 가독성과 유지보수성을 높이기 위해, 이 값을 UserInfoViewModelcompanion objectconst val UNSELECTED_ID = -1와 같이 상수로 정의하고, -1 대신 이 상수를 사용하는 것을 고려해 보세요. 이 변경은 이 파일의 loadDepartmentList 함수와 UserInfoActivity에도 적용될 수 있습니다.

@HI-JIN2 HI-JIN2 self-assigned this Feb 27, 2026
@HI-JIN2 HI-JIN2 changed the title fix: prevent departments lookup with invalid collegeId [Fix] collegeId=-1일시 API 요청 안되게 수정 Feb 27, 2026
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