-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Google Drive - add error handling / retries for creating subscriptions #16931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis update introduces a retry mechanism with exponential backoff for Google Drive API calls that may encounter HTTP 422 errors, specifically targeting rate limit issues when creating file subscriptions. The new logic is encapsulated in a helper method and applied to relevant methods. All other changes are version number increments. Changes
Sequence Diagram(s)sequenceDiagram
participant Trigger
participant GoogleDriveApp
Trigger->>GoogleDriveApp: watchFile / watchDrive
GoogleDriveApp->>GoogleDriveApp: retryWithExponentialBackoff(apiCall)
alt Success on first try
GoogleDriveApp-->>Trigger: API response
else 422 error encountered
GoogleDriveApp->>GoogleDriveApp: Wait (exponential backoff)
GoogleDriveApp->>GoogleDriveApp: Retry apiCall (up to maxAttempts)
alt Success on retry
GoogleDriveApp-->>Trigger: API response
else Max attempts reached or non-422 error
GoogleDriveApp-->>Trigger: Error thrown
end
end
Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes found. Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/google_drive/actions/create-file-from-template/create-file-from-template.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/google_drive/actions/add-file-sharing-preference/add-file-sharing-preference.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/google_drive/actions/create-shared-drive/create-shared-drive.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
components/google_drive/google_drive.app.mjs (1)
1478-1504: Well-implemented retry mechanism with exponential backoff.The implementation correctly handles HTTP 422 errors with appropriate retry logic:
✅ Strengths:
- Proper error status extraction from multiple error formats
- Correct exponential backoff calculation (1s, 2s, 4s delays)
- Informative logging with retry attempt details
- Focused on 422 errors (appropriate for rate limiting)
- Reasonable default parameters
✅ Edge cases handled:
- Re-throws errors when max attempts exceeded
- Only retries specific error status (422)
- Comprehensive error message extraction
Optional enhancement: Consider adding jitter to prevent thundering herd issues:
- const delayMs = Math.pow(baseDelayS, attempt) * 1000; + const baseDelayMs = Math.pow(baseDelayS, attempt) * 1000; + const jitter = Math.random() * 0.1 * baseDelayMs; // 10% jitter + const delayMs = baseDelayMs + jitter;However, this is not critical for the current use case and the implementation works well as-is.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (43)
components/google_drive/actions/add-file-sharing-preference/add-file-sharing-preference.mjs(1 hunks)components/google_drive/actions/copy-file/copy-file.mjs(1 hunks)components/google_drive/actions/create-file-from-template/create-file-from-template.mjs(1 hunks)components/google_drive/actions/create-file-from-text/create-file-from-text.mjs(1 hunks)components/google_drive/actions/create-folder/create-folder.mjs(1 hunks)components/google_drive/actions/create-shared-drive/create-shared-drive.mjs(1 hunks)components/google_drive/actions/delete-file/delete-file.mjs(1 hunks)components/google_drive/actions/delete-shared-drive/delete-shared-drive.mjs(1 hunks)components/google_drive/actions/download-file/download-file.mjs(1 hunks)components/google_drive/actions/find-file/find-file.mjs(1 hunks)components/google_drive/actions/find-folder/find-folder.mjs(1 hunks)components/google_drive/actions/find-forms/find-forms.mjs(1 hunks)components/google_drive/actions/find-spreadsheets/find-spreadsheets.mjs(1 hunks)components/google_drive/actions/get-file-by-id/get-file-by-id.mjs(1 hunks)components/google_drive/actions/get-folder-id-for-path/get-folder-id-for-path.mjs(1 hunks)components/google_drive/actions/get-shared-drive/get-shared-drive.mjs(1 hunks)components/google_drive/actions/list-access-proposals/list-access-proposals.mjs(1 hunks)components/google_drive/actions/list-files/list-files.mjs(1 hunks)components/google_drive/actions/move-file-to-trash/move-file-to-trash.mjs(1 hunks)components/google_drive/actions/move-file/move-file.mjs(1 hunks)components/google_drive/actions/resolve-access-proposal/resolve-access-proposal.mjs(1 hunks)components/google_drive/actions/search-shared-drives/search-shared-drives.mjs(1 hunks)components/google_drive/actions/update-file/update-file.mjs(1 hunks)components/google_drive/actions/update-shared-drive/update-shared-drive.mjs(1 hunks)components/google_drive/actions/upload-file/upload-file.mjs(1 hunks)components/google_drive/google_drive.app.mjs(3 hunks)components/google_drive/package.json(1 hunks)components/google_drive/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs(1 hunks)components/google_drive/sources/changes-to-specific-files/changes-to-specific-files.mjs(1 hunks)components/google_drive/sources/new-access-proposal/new-access-proposal.mjs(1 hunks)components/google_drive/sources/new-files-instant/new-files-instant.mjs(1 hunks)components/google_drive/sources/new-files-shared-drive/new-files-shared-drive.mjs(1 hunks)components/google_drive/sources/new-or-modified-comments/new-or-modified-comments.mjs(1 hunks)components/google_drive/sources/new-or-modified-files/new-or-modified-files.mjs(1 hunks)components/google_drive/sources/new-or-modified-folders/new-or-modified-folders.mjs(1 hunks)components/google_drive/sources/new-shared-drive/new-shared-drive.mjs(1 hunks)components/google_drive/sources/new-spreadsheet/new-spreadsheet.mjs(1 hunks)components/google_sheets/package.json(1 hunks)components/google_sheets/sources/new-comment/new-comment.mjs(1 hunks)components/google_sheets/sources/new-row-added-polling/new-row-added-polling.mjs(1 hunks)components/google_sheets/sources/new-row-added/new-row-added.mjs(1 hunks)components/google_sheets/sources/new-updates/new-updates.mjs(1 hunks)components/google_sheets/sources/new-worksheet/new-worksheet.mjs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
- GitHub Check: Lint Code Base
🔇 Additional comments (44)
components/google_sheets/sources/new-worksheet/new-worksheet.mjs (1)
12-12: Version bump looks correct
The component’s version has been updated from0.1.11to0.1.12with no other functional changes. Ensure this aligns with the versioning strategy across related Google Sheets and Drive components.components/google_sheets/sources/new-updates/new-updates.mjs (1)
12-12: Version bump is correct
Updating the version from "0.2.8" to "0.2.9" aligns with the coordinated package release.components/google_sheets/sources/new-comment/new-comment.mjs (1)
9-9: Version bump approved.The component version has been correctly incremented from 0.0.6 to 0.0.7. This aligns with the coordinated release updates across Google Sheets components in this PR. No functional changes detected.
components/google_sheets/package.json (1)
3-3: Package version updated correctly.The package version of
@pipedream/google_sheetshas been bumped from 0.8.2 to 0.8.3. This matches the version increments in the related component files. No other changes in package metadata.components/google_sheets/sources/new-row-added-polling/new-row-added-polling.mjs (1)
11-11: Version bump is consistent.The source version was updated from 0.0.2 to 0.0.3, in line with other Google Sheets polling sources in this PR. No functional impact.
components/google_sheets/sources/new-row-added/new-row-added.mjs (1)
11-11: Version increment looks good.Version has been correctly advanced from 0.1.10 to 0.1.11, consistent with the PR’s coordinated release. No logic changes introduced.
components/google_drive/actions/get-file-by-id/get-file-by-id.mjs (1)
8-8: Version bump approved.The action version has been updated from 0.0.5 to 0.0.6. This aligns with the broader component versioning in this pull request. No other modifications to the action logic.
components/google_drive/actions/delete-file/delete-file.mjs (1)
8-8: Approve version bump
The action version has been correctly incremented from "0.1.9" to "0.1.10" to align with the coordinated release.components/google_drive/package.json (1)
3-3: Approve package version update
The package version is updated from "0.9.1" to "0.9.2", matching the collective component version bumps for this release.components/google_drive/actions/find-spreadsheets/find-spreadsheets.mjs (1)
9-9: Approve version bump
The "Find Spreadsheets" action version is correctly updated from "0.1.8" to "0.1.9" as part of the minor release.components/google_drive/actions/delete-shared-drive/delete-shared-drive.mjs (1)
7-7: Approve version bump
The "Delete Shared Drive" action version has been bumped from "0.1.8" to "0.1.9", consistent with other drive actions.components/google_drive/actions/search-shared-drives/search-shared-drives.mjs (1)
7-7: Approve version bump
The "Search for Shared Drives" action version is correctly incremented from "0.1.9" to "0.1.10" to reflect the coordinated update.components/google_drive/actions/list-files/list-files.mjs (1)
8-8: Consistent version bump
The version has been correctly updated from "0.1.12" to "0.1.13", matching the coordinated minor version increments across the Google Drive action components.components/google_drive/actions/copy-file/copy-file.mjs (1)
7-7: Consistent version bump
The version has been correctly updated from "0.1.8" to "0.1.9", in line with the other Google Drive action components’ version increments.components/google_drive/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs (1)
30-30: Consistent version bump
The source version has been updated from "0.2.5" to "0.2.6", maintaining uniform versioning across Drive sources in this PR.components/google_drive/actions/create-file-from-template/create-file-from-template.mjs (1)
11-11: Consistent version bump
The version has been updated from "0.1.8" to "0.1.9", consistent with the batch of version increments across Drive actions.components/google_drive/actions/get-folder-id-for-path/get-folder-id-for-path.mjs (1)
15-15: Consistent version bump
The version has been incremented from "0.1.10" to "0.1.11", aligning with the series of minor version updates across Google Drive actions.components/google_drive/actions/move-file/move-file.mjs (1)
7-7: Approve version bump
The action version has been incremented from "0.1.8" to "0.1.9" without any changes to logic or error handling, keeping it consistent with other Google Drive components in this PR.components/google_drive/actions/update-file/update-file.mjs (1)
12-12: Approve version bump
The action version has been updated from "1.0.1" to "1.0.2" with no code or behavioral changes. This aligns with the coordinated versioning across the Google Drive actions.components/google_drive/actions/find-forms/find-forms.mjs (1)
9-9: Approve version bump
The action version has been bumped from "0.0.9" to "0.0.10" only. No logic or error handling changes were introduced here.components/google_drive/sources/new-files-instant/new-files-instant.mjs (1)
13-13: Approve version bump
The source version has been increased from "0.1.13" to "0.1.14" with no functional updates. This matches the versioning pattern for other Google Drive sources.components/google_drive/sources/new-access-proposal/new-access-proposal.mjs (1)
9-9: Approve version bump
The source version is updated from "0.0.1" to "0.0.2". There are no accompanying code changes beyond the version increment.components/google_drive/actions/create-file-from-text/create-file-from-text.mjs (1)
8-8: Version bump is correct and consistent.The action version has been updated from "0.2.1" to "0.2.2" in line with the coordinated version increments across all Google Drive components for this release.
components/google_drive/actions/create-shared-drive/create-shared-drive.mjs (1)
7-7: Version bump is correct and consistent.The action version has been updated from "0.1.9" to "0.1.10" matching the PR-wide metadata updates.
components/google_drive/actions/move-file-to-trash/move-file-to-trash.mjs (1)
8-8: Version bump is correct and consistent.The action version has been updated from "0.1.8" to "0.1.9", aligning with other Google Drive action version updates.
components/google_drive/sources/new-files-shared-drive/new-files-shared-drive.mjs (1)
10-10: Version bump is correct and consistent.The source version has been updated from "0.0.2" to "0.0.3" in sync with the PR’s coordinated version increments.
components/google_drive/actions/add-file-sharing-preference/add-file-sharing-preference.mjs (1)
23-23: Version bump is correct and consistent.The action version has been updated from "0.2.1" to "0.2.2", aligning with the broader version updates across Google Drive actions.
components/google_drive/sources/new-or-modified-files/new-or-modified-files.mjs (1)
27-27: Version bump is correct.Updating the source version to "0.3.6" aligns with the coordinated versioning across Google Drive components. No functional changes detected in this file.
components/google_drive/actions/update-shared-drive/update-shared-drive.mjs (1)
7-7: Version bump is correct.The action version has been updated from "0.1.8" to "0.1.9" with no other changes. This aligns with the overall package release.
components/google_drive/actions/download-file/download-file.mjs (1)
21-21: Version bump is correct.Updated version to "0.1.9" consistently with the rest of the Google Drive actions. No logic modifications detected.
components/google_drive/actions/create-folder/create-folder.mjs (1)
16-16: Version bump is correct.Action version updated to "0.1.10". Change solely reflects version increment, matching the coordinated release.
components/google_drive/actions/find-folder/find-folder.mjs (1)
10-10: Version bump is correct.Bumped action version to "0.1.9" without altering logic. This is consistent with the other Google Drive components.
components/google_drive/actions/find-file/find-file.mjs (1)
9-9: Approve version bump to 0.1.9
The change updates the action’s version from "0.1.8" to "0.1.9", which aligns with the coordinated release alongside the new retry logic. No functional code was modified.components/google_drive/actions/get-shared-drive/get-shared-drive.mjs (1)
7-7: Approve version bump to 0.1.9
Version increment from "0.1.8" to "0.1.9" is consistent with other actions in this PR and introduces no behavioral changes.components/google_drive/sources/new-or-modified-comments/new-or-modified-comments.mjs (1)
20-20: Approve version bump to 1.0.5
The source version is correctly updated from "1.0.4" to "1.0.5", matching the broader set of component releases. No logic changes detected.components/google_drive/sources/new-or-modified-folders/new-or-modified-folders.mjs (1)
23-23: Approve version bump to 0.1.11
Updated from "0.1.10" to "0.1.11" to stay in sync with the release versioning. No functional code was altered.components/google_drive/actions/list-access-proposals/list-access-proposals.mjs (1)
7-7: Approve version bump to 0.0.2
The action’s version has been correctly bumped from "0.0.1" to "0.0.2" in line with the package release. No other changes present.components/google_drive/sources/new-spreadsheet/new-spreadsheet.mjs (1)
9-9: Component version bump Updated the version string to "0.1.11" to align with the coordinated release of Google Drive sources.components/google_drive/sources/new-shared-drive/new-shared-drive.mjs (1)
8-8: Component version bump Incremented version to "0.1.9" to stay in sync with the Google Drive package release.components/google_drive/actions/resolve-access-proposal/resolve-access-proposal.mjs (1)
8-8: Action version bump Updated the action version to "0.0.2" as part of the overall Google Drive component version synchronization.components/google_drive/actions/upload-file/upload-file.mjs (1)
16-16: Action version bump Bumped the upload-file action version to "1.0.3" to reflect the new release cycle.components/google_drive/sources/changes-to-specific-files/changes-to-specific-files.mjs (1)
18-18: Source version bump Updated version to "0.2.6" in line with the batch version updates across Google Drive components.components/google_drive/google_drive.app.mjs (2)
732-733: LGTM! Proper integration of retry mechanism.The refactoring correctly wraps the API call in a function and uses the new retry mechanism while preserving the original response handling.
747-752: LGTM! Consistent implementation pattern.The watchFile method correctly follows the same retry integration pattern as watchDrive, properly capturing parameters in the closure and maintaining response structure.
luancazarine
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @michelle0927, LGTM! Ready for QA!
Resolves #16905
Summary by CodeRabbit
New Features
Chores