Skip to content

Conversation

@GTFalcao
Copy link
Collaborator

@GTFalcao GTFalcao commented Nov 14, 2025

Created as an alternative to existing webhook-based sources

Supports shared drives, and provides optional filters for specific files, specific folders, and "new files only".

Summary by CodeRabbit

  • New Features

    • Introduced a new polling source to monitor new and modified files in Google Drive with configurable drive selection, file and folder filtering, and an option to emit only newly created files.
  • Chores

    • Version bump to 1.3.0

@vercel
Copy link

vercel bot commented Nov 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
pipedream-docs Ignored Ignored Nov 14, 2025 10:19pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Nov 14, 2025 10:19pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Walkthrough

Version 1.3.0 of the Google Drive component adds a new polling source that monitors Google Drive for new or modified files. The source includes configuration for drive selection, optional file and folder filters, deployment-time state initialization with sample events, and a polling loop that streams changes and updates persistent state.

Changes

Cohort / File(s) Summary
Version Management
components/google_drive/package.json
Bump version from 1.2.0 to 1.3.0
New Polling Source
components/google_drive/sources/new-or-modified-files-polling/new-or-modified-files-polling.mjs
Implement new polling source with key, name, description, version, and polling timer; configure with googleDrive app, drive selection, optional file/folder filters, and newFilesOnly toggle; deploy hook initializes page token and last run timestamp with sample events; run loop streams changed files via listChanges, applies filtering, and emits events; include helper methods for drive ID retrieval, filtering logic, event metadata generation, and state storage
Test Fixture
components/google_drive/sources/new-or-modified-files-polling/test-event.mjs
Export mock Google Drive file metadata object for testing event handling and polling workflows

Sequence Diagram(s)

sequenceDiagram
    participant Deploy as Deployment
    participant Source as Polling Source
    participant Drive as Google Drive API
    participant DB as State Storage
    participant Emit as Event Emitter

    rect rgba(100, 150, 255, 0.3)
    Note over Deploy,Emit: Deploy Phase (Bootstrap)
    Deploy->>Source: Initialize source
    Source->>DB: Set initial pageToken and lastRunTimestamp
    Source->>Drive: List recent modified files (last 30 days)
    Drive-->>Source: File metadata (up to 5 non-folders)
    Source->>Emit: Emit sample events
    end

    rect rgba(100, 200, 100, 0.3)
    Note over Deploy,Emit: Polling Loop (Recurring)
    loop Each poll interval
        Source->>DB: Retrieve pageToken, driveId, lastRunTimestamp
        Source->>Drive: listChanges(pageToken, driveId)
        Drive-->>Source: Changed files page
        Source->>Source: shouldProcess: filter folders,<br/>apply newFilesOnly,<br/>match file/folder IDs
        Source->>Emit: Emit qualified events with metadata
        Source->>DB: Update pageToken
    end
    Source->>DB: Update lastRunTimestamp after all pages
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • new-or-modified-files-polling.mjs: Requires careful review of multi-layered filtering logic (newFilesOnly, file/folder matching, folder exclusion), streaming/pagination patterns, state management (pageToken and lastRunTimestamp storage), and integration points with the Google Drive API
  • Filtering and state update logic: Verify shouldProcess filter order and edge cases, and ensure pageToken and lastRunTimestamp are updated correctly to prevent event duplication or data loss

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description lacks a required WHY section as specified in the template. It provides context about the polling approach and features but does not explain the motivation behind this change. Add a WHY section explaining the motivation for introducing a polling-based alternative to webhook-based sources.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding a new polling source for Google Drive file detection, which is the primary purpose of this pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch drive-polling-source

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f97c22 and 399f192.

📒 Files selected for processing (3)
  • components/google_drive/package.json (1 hunks)
  • components/google_drive/sources/new-or-modified-files-polling/new-or-modified-files-polling.mjs (1 hunks)
  • components/google_drive/sources/new-or-modified-files-polling/test-event.mjs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
components/google_drive/sources/new-or-modified-files-polling/new-or-modified-files-polling.mjs (1)
components/google_drive/google_drive.app.mjs (1)
  • changedFiles (424-426)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Lint Code Base
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
🔇 Additional comments (2)
components/google_drive/package.json (1)

3-3: Version bump looks appropriate

The version update to 1.3.0 is consistent with adding a new source and has no functional risk by itself.

components/google_drive/sources/new-or-modified-files-polling/new-or-modified-files-polling.mjs (1)

177-218: Confirm listChanges token semantics to avoid reprocessing or 4xx errors

The run loop is structured well, but its correctness depends on how googleDrive.listChanges handles tokens:

const changedFilesStream = this.googleDrive.listChanges(pageToken, driveId);

for await (const changedFilesPage of changedFilesStream) {
  const { changedFiles, nextPageToken } = changedFilesPage;
  ...
  this._setPageToken(nextPageToken);
}
...
this._setLastRunTimestamp(currentRunTimestamp);

Please verify that:

  • nextPageToken is always the correct token to resume from on the next run (e.g., it already accounts for newStartPageToken from the Drive API), and
  • It’s safe to persist nextPageToken even on the last page (i.e., it does not end up undefined in a way that breaks subsequent calls or causes reprocessing).

If listChanges already normalizes this, great; if not, you may want to guard the _setPageToken call or explicitly handle a final newStartPageToken.

Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Left a couple comments. I'll leave it up to you, but I wonder if it would be simpler to just have one of either files or folders.

Comment on lines +31 to +48
files: {
type: "string[]",
label: "Files",
description: "The specific file(s) you want to watch for changes. Leave blank to watch all files in the Drive. Note that events will only be emitted for files directly in these folders (not in their subfolders, unless also selected here)",
optional: true,
default: [],
options({ prevContext }) {
const { nextPageToken } = prevContext;
return this.googleDrive.listFilesOptions(nextPageToken, this.getListFilesOpts());
},
},
folders: {
type: "string[]",
label: "Folders",
description: "The specific folder(s) to watch for changes. Leave blank to watch all folders in the Drive.",
optional: true,
default: [],
options({ prevContext }) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason not to use the fileId & folderId propDefinitions from the app file?

Comment on lines +141 to +154
// Check if specific files are being watched
if (this.files?.length > 0) {
if (!this.files.includes(file.id)) {
return false;
}
}

// Check if specific folders are being watched
if (this.folders?.length > 0) {
const watchedFolders = new Set(this.folders);
if (!file.parents || !file.parents.some((p) => watchedFolders.has(p))) {
return false;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user can specify both files and folders. But if the changed file is in a watched folder, but isn't one of the selected files, it will return early.

@michelle0927 michelle0927 moved this from Ready for PR Review to Changes Required in Component (Source and Action) Backlog Nov 14, 2025
@vunguyenhung vunguyenhung moved this from Changes Required to Ready for QA in Component (Source and Action) Backlog Nov 14, 2025
@vunguyenhung
Copy link
Collaborator

@vunguyenhung vunguyenhung moved this from Ready for QA to Ready for Release in Component (Source and Action) Backlog Nov 14, 2025
@vunguyenhung
Copy link
Collaborator

Hi everyone, all test cases are passed! Ready for release!

Test reports

@michelle0927 michelle0927 merged commit 8d9de72 into master Nov 15, 2025
10 checks passed
@michelle0927 michelle0927 deleted the drive-polling-source branch November 15, 2025 16:46
@github-project-automation github-project-automation bot moved this from Ready for Release to Done in Component (Source and Action) Backlog Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants