fix: handle 404 for missing Gmail labels in thread sync#37
fix: handle 404 for missing Gmail labels in thread sync#37Shekhar0109 wants to merge 5 commits intortCamp:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses Issue #28 where Gmail incremental sync fails with a 404 error when a label no longer exists. The fix wraps the Gmail History API call in a try-except block to catch and handle missing labels gracefully, allowing the sync to continue with other valid labels.
Changes:
- Added exception handling for HttpError with "notFound" reason in the Gmail history API call
- Introduced logic to remove missing labels from the Gmail account and continue syncing other labels
- Replaced the previous behavior of resetting history ID and stopping sync entirely
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
frappe_gmail_thread/frappe_gmail_thread/doctype/gmail_thread/gmail_thread.py
Outdated
Show resolved
Hide resolved
frappe_gmail_thread/frappe_gmail_thread/doctype/gmail_thread/gmail_thread.py
Show resolved
Hide resolved
frappe_gmail_thread/frappe_gmail_thread/doctype/gmail_thread/gmail_thread.py
Outdated
Show resolved
Hide resolved
frappe_gmail_thread/frappe_gmail_thread/doctype/gmail_thread/gmail_thread.py
Show resolved
Hide resolved
frappe_gmail_thread/frappe_gmail_thread/doctype/gmail_thread/gmail_thread.py
Outdated
Show resolved
Hide resolved
|
Thanks for contributing. See this issue: #37 (comment)
This is a valid argument. There may be errors beside just |
…mail_thread.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…mail_thread.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…mail_thread.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Thanks for the review. I have updated the 404 handling logic to properly distinguish between an expired startHistoryId and a genuinely missing label. On receiving a 404:
Regarding confirmation: I tested the behavior and confirmed that an invalid/expired startHistoryId also results in a 404. Therefore, explicit label verification was added to avoid incorrect removal. Please let me know if any additional changes are needed. |
|
@Shekhar0109 Thanks for the prompt resolution. I'll test it on my local in a few days and if everything goes well, we'll merge it. |
Description
This PR fixes Issue #28 where the Gmail incremental sync was failing with a 404 error whenever a label no longer existed. Previously, this caused the sync to stop completely, even if other labels were still valid.
Changes Made
try-exceptblock to catchgoogleapiclient.errors.HttpError.notFoundreason when a label is missing.gmail_account.label_idsand commit the change.Why
This ensures that the sync process is robust: missing labels are handled gracefully without interrupting the sync of other valid labels.
Relevant Technical Choices
Testing Instructions
gmail_thread.syncmethod.gmail_account.label_ids.Additional Information
Checklist
Fixes #28