feat(trigger): add Google Sheets, Drive, and Calendar polling triggers#4081
feat(trigger): add Google Sheets, Drive, and Calendar polling triggers#4081waleedlatif1 wants to merge 12 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview Wires these triggers into the Google blocks via Updates idempotency to support Reviewed by Cursor Bugbot for commit 47c7b3e. Configure here. |
Greptile SummaryThis PR adds polling triggers for Google Sheets (new rows), Google Drive (file changes), and Google Calendar (event updates). It introduces a Confidence Score: 5/5Safe to merge — all previously raised data-integrity concerns are resolved and the only remaining finding is a minor P2 style inconsistency in error messaging. All critical issues from prior review rounds (cursor/timestamp revert on failure, partial-failure handling, rate-limit classification for Calendar and Sheets, Drive merge-order, resume-token overshoot) have been addressed. The retryFailures idempotency extension is correctly implemented with no infinite-loop risk. The sole remaining finding is a P2 suggestion to align Drive 403/429 error messaging with Calendar and Sheets for easier log diagnostics. apps/sim/lib/webhooks/polling/google-drive.ts — missing explicit 403/429 rate-limit error classification in fetchChanges/getStartPageToken (P2 only) Important Files Changed
Sequence DiagramsequenceDiagram
participant Scheduler as Trigger.dev
participant Poller as Poll Handler
participant GoogleAPI as Google API
participant Idempotency as pollingIdempotency
participant DB as Webhook State
Scheduler->>Poller: pollWebhook(ctx)
Poller->>DB: read providerConfig
alt First poll
Poller->>GoogleAPI: get start cursor or seed row count
GoogleAPI-->>Poller: initial state
Poller->>DB: persist seeded state
Poller-->>Scheduler: success, no events emitted
else Subsequent polls
Poller->>GoogleAPI: fetch changes since last state
GoogleAPI-->>Poller: events or rows
loop For each item
Poller->>Idempotency: executeWithIdempotency(key, op)
alt Cache hit
Idempotency-->>Poller: cached result, no re-fire
else New execution
Idempotency->>Poller: run op
alt Success
Poller-->>Idempotency: result stored as completed
else Failure
Poller-->>Idempotency: key deleted for retry
end
end
end
alt anyFailed is true
Poller->>DB: revert state to pre-poll values
else All succeeded
Poller->>DB: advance state to new cursor or timestamp
end
end
Reviews (7): Last reviewed commit: "fix(polling): revert drive cursor on any..." | Re-trigger Greptile |
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
3d6edeb to
e14ff04
Compare
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 104690d. Configure here.
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 47c7b3e. Configure here.
Add polling triggers for Google Sheets (new rows), Google Drive (file changes via changes.list API), and Google Calendar (event updates via updatedMin). Each includes OAuth credential support, configurable filters (event type, MIME type, folder, search term, render options), idempotency, and first-poll seeding. Wire triggers into block configs and regenerate integrations.json. Update add-trigger skill with polling instructions and versioned block wiring guidance. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix Drive cursor stall: use nextPageToken as resume point when breaking early from pagination instead of re-using the original token - Eliminate redundant Drive API call in Sheets poller by returning modifiedTime from the pre-check function - Add 403/429 rate-limit handling to Sheets API calls matching the Calendar handler pattern - Remove unused changeType field from DriveChangeEntry interface - Rename triggers/google_drive to triggers/google-drive for consistency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
isDriveFileUnchanged short-circuited when lastModifiedTime was undefined, never calling the Drive API — so currentModifiedTime was never populated, creating a permanent chicken-and-egg loop. Now always calls the Drive API and returns the modifiedTime regardless of whether there's a previous value to compare against. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix fetchHeaderRow to throw on 403/429 rate limits instead of silently returning empty headers (prevents rows from being processed without headers and lastKnownRowCount from advancing past them permanently) - Fix Drive pagination to avoid advancing resume cursor past sliced changes (prevents permanent change loss when allChanges > maxFiles) - Remove unused logger import from Google Drive trigger config
…empotency key - Sheets: only advance lastKnownRowCount by processedCount when there are failures, so failed rows are retried on the next poll cycle (idempotency deduplicates already-processed rows on re-fetch) - Drive: add fallback for change.time in idempotency key to prevent key collisions if the field is ever absent from the API response
… Drive API failure - Remove unused `now` variable from Google Drive polling handler - Preserve stored lastModifiedTime when Drive API pre-check fails (previously wrote undefined, disabling the optimization until the next successful Drive API call)
… calendar, drive handlers
…ot, fix calendar inclusive updatedMin
- Add 'trigger-advanced' mode to SubBlockConfig so canonical pairs work in trigger mode - Fix buildCanonicalIndex: trigger-mode subblocks don't overwrite non-trigger basicId, deduplicate advancedIds from block spreads - Update editor, subblock layout, and trigger config aggregation to include trigger-advanced subblocks - Replace dropdown+fetchOptions in Calendar/Sheets/Drive pollers with file-selector (basic) + short-input (advanced) canonical pairs - Add canonicalParamId: 'oauthCredential' to triggerCredentials for selector context resolution - Update polling handlers to read canonical fallbacks (calendarId||manualCalendarId, etc.)
47c7b3e to
2180127
Compare
Summary
changes.listAPI with opaque cursor (no clock skew, catches deletes)updatedMin+singleEvents=true(expanded recurring events)modifiedTimepre-check (saves Sheets quota)generate-docs.tsdiscovers themintegrations.jsonwith new trigger entriesadd-triggerskill with polling instructions and versioned block wiring guidanceType of Change
Testing
Tested manually — type-check passes, lint passes,
integrations.jsonregenerated correctlyChecklist