Skip to content

Conversation

@kwon204
Copy link
Contributor

@kwon204 kwon204 commented May 18, 2025

#️⃣ 연관된 이슈>

📝 작업 내용> 이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지 첨부 가능)

  • 구글 캘린더 일정과 서비스 일정을 동기화할 때 사용하는 sync_token이 만료되는 경우입니다.
  • 만료되는 경우 sync_token만 재발급 받을 수 없기 때문에 일정들을 모두 가져오는 API를 사용해서 sync_token을 새로 업데이트 해야 합니다.
  • 이전에는 sync_token이 만료되는 경우에 3번 재시도를 하였습니다.
  • 이러한 재시도는 만료된 sync_token을 사용한 재시도이기 때문에 불필요합니다.
  • 따라서 재시도 없이 바로 예외를 발생시켜 일정을 다시 가져오는 API를 사용하도록 변경합니다.
  • 로그인할 때 syncWithCalendar가 실행되는 것을 파악하지 못해서 수정하였습니다.
  • sync_token 만료 시 API URL을 전체 일정을 가져오는 API로 수정해서 요청하도록 변경하였습니다.

🙏 여기는 꼭 봐주세요! > 리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced calendar synchronization to better handle expired sync tokens by clearing them and retrying automatically.
  • Tests

    • Updated tests to verify successful retries and sync token clearing behavior during calendar synchronization.

@kwon204 kwon204 self-assigned this May 18, 2025
@kwon204 kwon204 requested a review from efdao as a code owner May 18, 2025 09:19
@kwon204 kwon204 added the 🛠️ BE Backend label May 18, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 18, 2025

Walkthrough

The changes update the handling of the GC_EXPIRED_SYNC_TOKEN error in the RetryExecutor utility to log the error code instead of the message. The retry logic now clears the sync token and continues retrying rather than immediately rethrowing. Corresponding test logic was updated to verify successful retry behavior and clearing of the sync token. Additionally, sync token retrieval and logging were moved inside the retry lambda in the calendar synchronization method.

Changes

File(s) Change Summary
backend/src/main/java/endolphin/backend/global/util/RetryExecutor.java Changed logging to use error codes; on GC_EXPIRED_SYNC_TOKEN, clears sync token and yields false to retry instead of rethrowing immediately.
backend/src/test/java/endolphin/backend/global/util/RetryExecutorTest.java Updated test to assert successful retry and clearing of sync token instead of expecting an exception.
backend/src/main/java/endolphin/backend/global/google/GoogleCalendarService.java Moved sync token retrieval, event URL construction, and logging inside the retry executor lambda.

Poem

A sync token once expired, we see,
Now cleared with care, so retries run free.
Logs tell the tale with error codes bright,
Tests cheer the success, no exception in sight.
Inside the retry, the token’s retold—
A rabbit’s hop in code, swift and bold! 🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 74fa133318be280b9633f48e944561879f7b32e8 and 61d84fb.

📒 Files selected for processing (3)
  • backend/src/main/java/endolphin/backend/global/google/GoogleCalendarService.java (1 hunks)
  • backend/src/main/java/endolphin/backend/global/util/RetryExecutor.java (1 hunks)
  • backend/src/test/java/endolphin/backend/global/util/RetryExecutorTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • backend/src/test/java/endolphin/backend/global/util/RetryExecutorTest.java
  • backend/src/main/java/endolphin/backend/global/util/RetryExecutor.java

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Join our Discord community for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@efdao
Copy link
Collaborator

efdao commented May 27, 2025

just ask; 클라이언트가 에러 응답을 보고 다시 요청을 보내는건가요?

kwon204 added 3 commits May 30, 2025 18:26
날리도록 수정

- 예외를 날린 후 구글 서버에 500 에러 응답을 보낸다.
- 500응답을 받은 구글 서버가 웹훅 알림을 한 번 더 보낸다.
- 이때 다시 일정을 가져오면서 sync_token을 업데이트한다.
- sync_token이 유효하지 않을 경우 재시도 하지 않고 예외를 발생 시키는 것으로
  수정
- 람다 함수 내부에서 url을 생성하도록 수정
@kwon204 kwon204 force-pushed the bugfix/be/sync-token-retry branch from 74fa133 to 61d84fb Compare May 30, 2025 09:27
@kwon204
Copy link
Contributor Author

kwon204 commented May 30, 2025

just ask; 클라이언트가 에러 응답을 보고 다시 요청을 보내는건가요?

로그인할 때 실행되는 것을 파악하지 못했습니다.
수정하겠습니다

Copy link
Collaborator

@efdao efdao Jun 1, 2025

Choose a reason for hiding this comment

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

getSyncToken을 재시도하는 이유가 뭘까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

요약: syncToken이 만료되었을 때 전체 일정을 가져오는 URL을 새로 생성하기 위해 사용합니다.

129번째 줄에서 url을 생성할 때 syncToken이 있다면 URL 쿼리에 syncToken을 추가하고 null 이라면 추가하지 않은(전체 일정을 가져오는) url을 생성합니다.

만약 API를 요청할 때 syncToken이 만료되거나 유효하지 않다면, RetryExecutor에서 DB의 syncToken을 null로 설정합니다. 그 이후에 재시도할 때는 이전에 사용한 URL이 아닌 syncToken이 포함되지 않은(전체 일정을 가져오는) URL로 재시도해야 합니다.

이전 코드를 보면 eventsUrl을 람다 함수 밖에서 만들어서 주입해주고 있는데요. 따로 조사한 결과, 람다 함수 외부에서 주입된 변수는 final로 처리되어 수정이 되지 않는다고 합니다. 따라서 새로 생성한 url을 적용하기 위해서 람다 함수 내부에서 url을 생성하기 위해 url 생성 과정에 필요한 getSyncToken을 재시도하고 있습니다.!

@kwon204 kwon204 requested a review from efdao June 7, 2025 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ BE Backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants