Skip to content
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

AWS S3 Upload Large Files #15386

Merged
merged 3 commits into from
Jan 24, 2025
Merged

AWS S3 Upload Large Files #15386

merged 3 commits into from
Jan 24, 2025

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Jan 23, 2025

Resolves #15382

Summary by CodeRabbit

  • New Features

    • Added ignoreDeleteMarkers option for S3 deleted file events
    • Added detectRestoreInitiation option for S3 restored file events
  • Improvements

    • Enhanced S3 file upload functionality using @aws-sdk/lib-storage
  • Version Updates

    • Updated package version to 0.7.2
    • Multiple component versions incremented across AWS actions and sources

Copy link

vercel bot commented Jan 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2025 9:46pm
pipedream-docs ⬜️ Ignored (Inspect) Jan 23, 2025 9:46pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jan 23, 2025 9:46pm

Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

Walkthrough

This pull request introduces updates to multiple AWS S3-related components, primarily focusing on improving file upload functionality and version increments. The most significant change is in the common-s3.mjs file, where the uploadFile method has been modified to use the Upload class from @aws-sdk/lib-storage instead of PutObjectCommand. Additionally, several components have had their version numbers incremented, and a new dependency has been added to the package.json file.

Changes

File Change Summary
components/aws/common/common-s3.mjs Replaced PutObjectCommand with Upload class for file uploads
components/aws/package.json Updated package version to 0.7.2 and added @aws-sdk/lib-storage dependency
Multiple S3 action/source files Version number increments from 0.x.y to 0.x.(y+1)

Assessment against linked issues

Objective Addressed Explanation
Update uploadFile to use Upload class
Handle large file uploads more effectively
Add @aws-sdk/lib-storage dependency

Possibly related PRs

Suggested labels

ai-assisted, aws, s3, bugfix

Suggested reviewers

  • GTFalcao

Poem

🚀 Uploading files with grace and might,
AWS S3 now shines so bright!
From PutObjectCommand to Upload we leap,
Large files no longer make developers weep! 🐰
Version numbers dance, one step ahead,
A rabbit's code update, smoothly led! 🌈


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@michelle0927 michelle0927 marked this pull request as ready for review January 23, 2025 21:48
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: 0

🧹 Nitpick comments (4)
components/aws/sources/s3-deleted-file/s3-deleted-file.mjs (1)

Line range hint 13-18: Consider enhancing the property documentation.

While the current description is clear, it would be helpful to add examples of when users might want to enable/disable this option, and explain the difference between delete markers (used in versioned buckets) vs permanent deletions.

components/aws/sources/s3-restored-file/s3-restored-file.mjs (2)

Line range hint 13-18: Consider enhancing the property documentation.

While the current description is clear, it would be helpful to add:

  1. Examples of when users might want to track restore initiation
  2. Explanation of the S3 Glacier restore lifecycle
  3. Expected time gaps between initiation and completion events

Line range hint 28-37: Update summary message to reflect restore initiation events.

When detectRestoreInitiation is enabled, the summary message should distinguish between initiation and completion events.

Consider updating the generateMeta method:

 generateMeta(data) {
   const { "x-amz-request-id": id } = data.responseElements;
   const { key } = data.s3.object;
   const { eventTime: isoTimestamp } = data;
+  const isInitiation = data.eventName === "s3:ObjectRestore:Post";
   return {
     id,
-    summary: `Restored file: '${key}'`,
+    summary: isInitiation
+      ? `Initiated restore for file: '${key}'`
+      : `Restored file: '${key}'`,
     ts: Date.parse(isoTimestamp),
   };
 };
components/aws/common/common-s3.mjs (1)

84-88: Consider adding error handling and progress tracking.

While the implementation is correct, consider these enhancements for better reliability and user experience:

  1. Add error handling
  2. Implement upload progress tracking

Here's a suggested implementation:

 async uploadFile(params) {
   const parallelUploads3 = new Upload({
     client: await this._clientS3(),
     params,
+    queueSize: 4, // optional: number of concurrent uploads
   });

+  // Optional: Track progress
+  parallelUploads3.on("httpUploadProgress", (progress) => {
+    console.log(progress.loaded, progress.total);
+  });

-  await parallelUploads3.done();
+  try {
+    await parallelUploads3.done();
+  } catch (err) {
+    // Handle specific errors
+    if (err.name === "AbortError") {
+      throw new Error("Upload aborted by user");
+    }
+    throw new Error(`Upload failed: ${err.message}`);
+  }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d6b117b and d50e242.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (13)
  • components/aws/actions/s3-download-file-to-tmp/s3-download-file-to-tmp.mjs (1 hunks)
  • components/aws/actions/s3-generate-presigned-url/s3-generate-presigned-url.mjs (1 hunks)
  • components/aws/actions/s3-stream-file/s3-stream-file.mjs (1 hunks)
  • components/aws/actions/s3-upload-file-tmp/s3-upload-file-tmp.mjs (1 hunks)
  • components/aws/actions/s3-upload-file-url/s3-upload-file-url.mjs (1 hunks)
  • components/aws/actions/s3-upload-file/s3-upload-file.mjs (1 hunks)
  • components/aws/common/common-s3.mjs (2 hunks)
  • components/aws/package.json (2 hunks)
  • components/aws/sources/new-emails-sent-to-ses-catch-all-domain/new-emails-sent-to-ses-catch-all-domain.mjs (1 hunks)
  • components/aws/sources/s3-deleted-file/s3-deleted-file.mjs (1 hunks)
  • components/aws/sources/s3-new-event/s3-new-event.mjs (1 hunks)
  • components/aws/sources/s3-new-file/s3-new-file.mjs (1 hunks)
  • components/aws/sources/s3-restored-file/s3-restored-file.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (9)
  • components/aws/actions/s3-stream-file/s3-stream-file.mjs
  • components/aws/actions/s3-download-file-to-tmp/s3-download-file-to-tmp.mjs
  • components/aws/actions/s3-upload-file-url/s3-upload-file-url.mjs
  • components/aws/actions/s3-upload-file/s3-upload-file.mjs
  • components/aws/sources/new-emails-sent-to-ses-catch-all-domain/new-emails-sent-to-ses-catch-all-domain.mjs
  • components/aws/sources/s3-new-event/s3-new-event.mjs
  • components/aws/actions/s3-upload-file-tmp/s3-upload-file-tmp.mjs
  • components/aws/sources/s3-new-file/s3-new-file.mjs
  • components/aws/actions/s3-generate-presigned-url/s3-generate-presigned-url.mjs
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (7)
components/aws/sources/s3-deleted-file/s3-deleted-file.mjs (2)

9-9: LGTM! Version bump is appropriate.

The version increment from 0.1.2 to 0.1.3 aligns with the addition of the new ignoreDeleteMarkers feature.


Line range hint 22-27: LGTM! Event filtering is implemented correctly.

The conditional event type selection based on ignoreDeleteMarkers is well implemented:

  • s3:ObjectRemoved:Delete for permanent deletions
  • s3:ObjectRemoved:* for all deletion events
components/aws/sources/s3-restored-file/s3-restored-file.mjs (2)

9-9: LGTM! Version bump is appropriate.

The version increment from 0.1.2 to 0.1.3 aligns with the addition of the new detectRestoreInitiation feature.


Line range hint 22-27: LGTM! Event filtering is implemented correctly.

The conditional event type selection based on detectRestoreInitiation is well implemented:

  • s3:ObjectRestore:* for both initiation and completion
  • s3:ObjectRestore:Completed for completion only
components/aws/common/common-s3.mjs (1)

11-11: LGTM! Good choice of library for large file uploads.

The addition of @aws-sdk/lib-storage is appropriate as it provides built-in support for multipart uploads and better handling of large files.

components/aws/package.json (2)

3-3: LGTM! Version bump follows semantic versioning.

The increment from 0.7.1 to 0.7.2 is appropriate for this enhancement.


28-28: Consider aligning AWS SDK dependency versions.

The new dependency @aws-sdk/lib-storage is on version ^3.734.0 while other AWS SDK dependencies are on older versions (^3.58.0 to ^3.731.0). Consider aligning all AWS SDK dependency versions for better compatibility and maintenance.

Let's check for any compatibility issues between these versions:

Copy link
Collaborator

@jcortes jcortes left a 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!

@michelle0927 michelle0927 merged commit 4546757 into master Jan 24, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-15382 branch January 24, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] AWS S3 Upload Large Files
2 participants