Skip to content

Conversation

@ikseong00
Copy link
Contributor

@ikseong00 ikseong00 commented Nov 20, 2025

🔗 관련 이슈

📙 작업 설명

  • 에러 발생 이유는 다음과 같습니다.
  1. 앱 삭제 시
    암호화 시 사용되었던 AES Keystore 가 삭제됨
    DataStore 등 내부 저장소 데이터도 삭제됨
  2. 앱 재설치 시
    새로운 UID 가 발급되고, AES Keystore 가 새로 생김
    DataStore 가 복구됨!! -> 이 값은 이전 AES Keystore 를 통해 암호화된 값임.
  3. 실행
    DataStore 에 값이 존재 -> decrypt 진행 -> 이전에 암호화된 값을 새로운 키로 복호화 하려고 함
    에러 발생
  • 해결 방법은 2가지가 있는 데 1안으로 선택했습니다.
  1. decrypt 함수를 try-catch 로 감싸기
    try catch 로 감싸서, 해당 예외가 발생 시 defaultValue 토큰으로 날림 -> 빈 토큰으로 인지해서 로그인화면으로 이동하게 됨
  2. 메니페스트 파일에서 자동저장, 불러오기 false
image

위 사진에서 allowBackup, fullBackupContent 에 false 값을 입력하면 되는 것 같습니다.

💬 추가 설명 or 리뷰 포인트 (선택)

@ikseong00 ikseong00 self-assigned this Nov 20, 2025
@ikseong00 ikseong00 added the fix label Nov 20, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 20, 2025

Walkthrough

토큰 암호화 및 직렬화 유틸리티 두 파일에 예외 처리 로직이 추가되었습니다. TokenEncryptordecrypt 메서드와 TokenSerializerreadFrom 메서드는 이제 try-catch 블록으로 래핑되어 예외 발생 시 안전한 기본값을 반환합니다.

Changes

Cohort / File(s) Change Summary
예외 처리 강화
app/src/main/java/com/konkuk/medicarecall/data/util/TokenEncryptor.kt
decrypt 메서드에 try-catch 블록 추가; 모든 예외 발생 시 빈 ByteArray 반환
직렬화 안정성 개선
app/src/main/java/com/konkuk/medicarecall/data/util/TokenSerializer.kt
readFrom 메서드를 try-catch로 감싸 예외 시 defaultValue 반환; Log import 추가; 디버그 로깅 구현

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant TokenSerializer
    participant TokenEncryptor
    participant Log
    
    Caller->>TokenSerializer: readFrom(input)
    
    rect rgb(230, 240, 250)
    Note over TokenSerializer: Try Block
    TokenSerializer->>TokenSerializer: 입력 읽기
    TokenSerializer->>TokenSerializer: Base64 디코드
    TokenSerializer->>TokenEncryptor: decrypt(bytes)
    
    rect rgb(240, 230, 250)
    Note over TokenEncryptor: Try Block
    TokenEncryptor->>TokenEncryptor: 복호화 수행
    TokenEncryptor-->>TokenSerializer: 복호화된 데이터
    end
    
    TokenSerializer->>TokenSerializer: JSON 역직렬화
    TokenSerializer-->>Caller: Token 반환
    end
    
    rect rgb(255, 240, 240)
    Note over TokenSerializer: Catch Block
    TokenSerializer->>Log: debug(exception)
    Log-->>TokenSerializer: 
    TokenSerializer-->>Caller: defaultValue 반환
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • 예외 처리 패턴의 일관성: 두 파일 모두 동일한 try-catch 구조 적용
  • 로깅 추가의 적절성 검토
  • 반환 값 변경이 호출 코드에 미치는 영향 확인

Poem

에러도 웰컴, 조용한 듯 미소 지으며 🤐
빈 바이트와 기본값으로 무사히 넘어가고,
로그에 남겨두고 계속 나아가네 📝✨


📜 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 114fd18 and 81b2456.

📒 Files selected for processing (2)
  • app/src/main/java/com/konkuk/medicarecall/data/util/TokenEncryptor.kt (1 hunks)
  • app/src/main/java/com/konkuk/medicarecall/data/util/TokenSerializer.kt (2 hunks)

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

Comment @coderabbitai help to get the list of available commands and usage tips.

@ProtossManse
Copy link
Collaborator

LGTM

@ikseong00 ikseong00 merged commit fd8ea41 into develop Nov 20, 2025
2 checks passed
@ikseong00 ikseong00 deleted the fix/token-decrypt-#198 branch November 20, 2025 13:04
@ikseong00 ikseong00 changed the title Fix: #198 토큰 복호화 실패 시 방어 로직 구현 [Fix] 토큰 복호화 실패 시 방어 로직 구현 #198 Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fix] 앱을 삭제하고 재설치한 뒤, 실행 시에 Exception 발생

3 participants