From 77fd865e05faea32e6cf5d2ad3489360197a85fb Mon Sep 17 00:00:00 2001 From: Eliezer Steinbock <3090527+elie222@users.noreply.github.com> Date: Tue, 6 Jan 2026 01:53:39 +0200 Subject: [PATCH] fix(webhook): add observability for Gmail history pagination MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apps/web/app/api/google/webhook/process-history.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/web/app/api/google/webhook/process-history.ts b/apps/web/app/api/google/webhook/process-history.ts index 38cde7854..a9c3a469d 100644 --- a/apps/web/app/api/google/webhook/process-history.ts +++ b/apps/web/app/api/google/webhook/process-history.ts @@ -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.