Skip to content

Commit

Permalink
fix(webhook): add observability for Gmail history pagination
Browse files Browse the repository at this point in the history
Log a warning when Gmail API returns nextPageToken, indicating more
history items exist beyond the 500 fetched. This provides visibility
into potential data loss without changing behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
  • Loading branch information
Eliezer Steinbock and Claude Opus 4.5 committed Jan 5, 2026
1 parent 06413c6 commit 77fd865
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/web/app/api/google/webhook/process-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ async function fetchGmailHistoryResilient({
historyTypes: ["messageAdded", "labelAdded", "labelRemoved"],
maxResults: 500,
});

if (data.nextPageToken) {
logger.warn("Gmail history has more pages that were not fetched", {
historyItemCount: data.history?.length ?? 0,
startHistoryId,
});
}

return { status: "success", data, startHistoryId };
} catch (error) {
// Gmail history IDs are typically valid for ~1 week. If older, Gmail returns a 404.
Expand Down

0 comments on commit 77fd865

Please sign in to comment.