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

fix: Amazon S3 large file uploads issue fixed #36584

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

sneha122
Copy link
Contributor

@sneha122 sneha122 commented Sep 27, 2024

Description

This PR fixes the file upload issue for S3. With S3 file upload, earlier users were able to upload files only upto 14mb but now with this PR fix they can upload larger files.

Fixes #35601
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11100760284
Commit: 38e0810
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Mon, 30 Sep 2024 07:11:48 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Enhanced object mapping capabilities with a new method to handle maximum string length for large data.
  • Bug Fixes
    • Improved handling of multipart data to prevent truncation during serialization.

Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

Walkthrough

The changes in this pull request involve enhancements to the BasePlugin and SerializationUtils classes within the appsmith-interfaces module. The objectMapper in BasePlugin has been updated to utilize a new method that accommodates larger string lengths when processing multipart data. This adjustment aims to resolve issues related to file uploads exceeding previously set limits.

Changes

File Change Summary
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/BasePlugin.java Updated objectMapper initialization to use getObjectMapperWithSourceInLocationAndMaxStringLengthEnabled().
app/server/appsmith-interfaces/src/main/java/com/appsmith/util/SerializationUtils.java Added new method getObjectMapperWithSourceInLocationAndMaxStringLengthEnabled() for handling larger string lengths.

Assessment against linked issues

Objective Addressed Explanation
Resolve file upload issue to S3 for large files (Issue #35601)

Suggested reviewers

  • ApekshaBhosale
  • sharat87

Poem

In the code where data flows,
A change to help the upload grows.
With limits set to stretch and bend,
File sizes large, we now commend!
So let’s rejoice in bytes anew,
As uploads soar, our dreams come true! 🎉


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 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.

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.

@sneha122
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions github-actions bot added the Bug Something isn't working label Sep 27, 2024
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11066862934.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36584.
recreate: .

@github-actions github-actions bot added File upload issues Issues related to uploading any type of files from within Appsmith High This issue blocks a user from building or impacts a lot of users Integrations Product Issues related to a specific integration Needs Triaging Needs attention from maintainers to triage Production Query & JS Pod Issues related to the query & JS Pod S3 Issues related to the S3 plugin labels Sep 27, 2024
Copy link

Deploy-Preview-URL: https://ce-36584.dp.appsmith.com

@sneha122 sneha122 added the ok-to-test Required label for CI label Sep 27, 2024
@sneha122
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11100778973.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36584.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-36584.dp.appsmith.com

@sneha122 sneha122 marked this pull request as ready for review September 30, 2024 09:54
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

🧹 Outside diff range and nitpick comments (1)
app/server/appsmith-interfaces/src/main/java/com/appsmith/util/SerializationUtils.java (1)

78-90: Excellent work on this new method, students!

This new addition to our SerializationUtils class is like upgrading our school library to accommodate larger books. It's a fantastic solution to our file size limitation problem.

A few points to note:

  1. The method name clearly describes its purpose. Good job!
  2. The comments explain the reasoning behind allowing maximum length. Remember, clear documentation is key to good coding practices.
  3. Setting maxStringLength to Integer.MAX_VALUE is a bold move. It's like removing the size limit on book reports. While it solves our immediate problem, we need to be cautious.

Consider adding a configurable parameter for maxStringLength instead of using Integer.MAX_VALUE directly. This would be like having an adjustable bookshelf that we can resize as needed. Here's an example:

-    public static ObjectMapper getObjectMapperWithSourceInLocationAndMaxStringLengthEnabled() {
+    public static ObjectMapper getObjectMapperWithSourceInLocationAndMaxStringLengthEnabled(int maxStringLength) {
         ObjectMapper objectMapper =
                 new ObjectMapper().enable(StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION.mappedFeature());
         // Multipart data would be parsed using object mapper, these files may be large in the size.
         // Hence, the length should not be truncated, therefore allowing maximum length.
         objectMapper
                 .getFactory()
                 .setStreamReadConstraints(StreamReadConstraints.builder()
-                        .maxStringLength(Integer.MAX_VALUE)
+                        .maxStringLength(maxStringLength)
                         .build());

         return objectMapper;
     }

This way, we can adjust the maximum string length as needed, providing more flexibility and control over resource usage.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6368215 and 38e0810.

📒 Files selected for processing (2)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/BasePlugin.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/util/SerializationUtils.java (2 hunks)
🔇 Additional comments (3)
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/BasePlugin.java (1)

10-11: Class, pay attention to this important change!

The modification in the objectMapper initialization is a significant improvement. Let's break it down:

  1. The new method getObjectMapperWithSourceInLocationAndMaxStringLengthEnabled() retains the previous functionality of source location while adding support for maximum string length.

  2. This change directly addresses the issue reported in [Bug]: File upload to S3 fails for certain files #35601, where users encountered errors when uploading files larger than 14MB due to string value length limitations.

  3. By enabling max string length handling, we're allowing our students (users) to upload larger files to Amazon S3 without running into those pesky errors. This is a valuable enhancement to our system's capabilities.

However, class, we must consider a few things:

  1. Performance: Handling very large strings might have some impact on performance. We should keep an eye on this and perhaps conduct some benchmarking tests.

  2. Testing: While the PR mentions that Cypress tests have passed, we should ensure thorough testing with various file sizes to confirm the fix works as expected.

  3. Documentation: It would be beneficial to update our user documentation to reflect this new capability.

Let's run a quick check to see if this change is consistent across our codebase:

Class, these tests will help us ensure consistency and verify the implementation. Any questions?

app/server/appsmith-interfaces/src/main/java/com/appsmith/util/SerializationUtils.java (2)

9-9: Class, pay attention to this new import!

The addition of com.fasterxml.jackson.core.StreamReadConstraints is a crucial step in our lesson plan. It's like bringing a new textbook to class that will help us handle larger amounts of information. Well done!


Line range hint 1-90: Class, let's summarize today's lesson!

The changes made to our SerializationUtils class are like upgrading our school's ability to handle larger textbooks. We've successfully addressed the issue of file size limitations, allowing our students (users) to upload larger files to Amazon S3.

Key points to remember:

  1. We've added a new import to bring in the tools we need.
  2. Our new method, getObjectMapperWithSourceInLocationAndMaxStringLengthEnabled, is the star of the show. It's like a new librarian who can handle books of any size.
  3. We've documented our work well, which is crucial for future students who might need to understand this code.

Overall, this is a significant improvement that will benefit many of our users. Great job, class!

To ensure we haven't missed anything, let's do a quick pop quiz:

This script will help us ensure that our new method is being used correctly and that we haven't left any old size limits or TODOs lying around. Remember, thorough testing is key to a successful project!

✅ Verification successful

Let's ensure everything is in order!

To double-check our work, let's perform one more quick search to confirm there are no hidden references to the old file size limits.


All verifications passed successfully!

Great job! All checks confirm that the SerializationUtils class has been updated correctly, with no remaining references to the old file size limits. The new method is properly utilized, and there are no lingering TODOs or outdated size constraints in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the new method is used correctly in the codebase

# Test 1: Check if the new method is used in the codebase
echo "Test 1: Searching for usage of getObjectMapperWithSourceInLocationAndMaxStringLengthEnabled"
rg --type java "getObjectMapperWithSourceInLocationAndMaxStringLengthEnabled"

# Test 2: Check for any remaining occurrences of the old 14MB limit
echo "Test 2: Searching for any remaining 14MB limits"
rg --type java "14.*MB"

# Test 3: Check for any TODOs related to file size limits
echo "Test 3: Searching for TODOs related to file size limits"
rg --type java "TODO.*file.*size"

Length of output: 927


Script:

#!/bin/bash
# Description: Verify no indirect references to the old 14MB file size limit

# Test 4: Search for any string mentions of '14MB' in comments or documentation
echo "Test 4: Searching for '14MB' in comments or documentation"
rg --type java "//.*14MB" 
rg --type md "14MB"

Length of output: 178

@NilanshBansal
Copy link
Contributor

Tested by uploading a 45 MB file in current prod env, it failed with the following error.
image

Uploading the same file worked on the DP

@sneha122
Copy link
Contributor Author

sneha122 commented Oct 1, 2024

This is kept on hold as I am verifying whether this change will result in huge eval timing on the frontend, as with this change we are allowing file uploads more than 15mb and we need to ensure that this does not cause any breaking on the frontend evaluations.
More info: https://theappsmith.slack.com/archives/CPQNLFHTN/p1727698255233839?thread_ts=1727435362.565589&cid=CPQNLFHTN

@sneha122 sneha122 merged commit 05d3822 into release Oct 1, 2024
47 checks passed
@sneha122 sneha122 deleted the fix/allow-large-file-uploads-s3 branch October 1, 2024 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working File upload issues Issues related to uploading any type of files from within Appsmith High This issue blocks a user from building or impacts a lot of users Integrations Product Issues related to a specific integration Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Production Query & JS Pod Issues related to the query & JS Pod S3 Issues related to the S3 plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: File upload to S3 fails for certain files
2 participants