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 #1402 Migrating AWS S3 SDK to v2 #1403

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

seratch
Copy link
Member

@seratch seratch commented Dec 5, 2024

This pull request resolves #1402

Category (place an x in each of the [ ])

  • bolt (Bolt for Java)
  • bolt-{sub modules} (Bolt for Java - optional modules)
  • slack-api-client (Slack API Clients)
  • slack-api-model (Slack API Data Models)
  • slack-api-*-kotlin-extension (Kotlin Extensions for Slack API Clients)
  • slack-app-backend (The primitive layer of Bolt for Java)

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you agree to those rules.

@seratch seratch added enhancement M-T: A feature request for new functionality project:bolt dependencies Pull requests that update a dependency file labels Dec 5, 2024
@seratch seratch added this to the 1.x milestone Dec 5, 2024
@seratch seratch self-assigned this Dec 5, 2024
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 45 lines in your changes missing coverage. Please review.

Project coverage is 73.59%. Comparing base (5b0212f) to head (8651a88).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...t/service/builtin/AmazonS3InstallationService.java 57.14% 26 Missing and 4 partials ⚠️
...olt/service/builtin/AmazonS3OAuthStateService.java 57.14% 13 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1403      +/-   ##
============================================
- Coverage     73.68%   73.59%   -0.10%     
+ Complexity     4389     4383       -6     
============================================
  Files           476      476              
  Lines         14139    14171      +32     
  Branches       1423     1430       +7     
============================================
+ Hits          10419    10429      +10     
- Misses         2882     2900      +18     
- Partials        838      842       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

boolean bucketExists = false;
Exception error = null;
try (S3Client s3 = createS3Client()) {
bucketExists = s3.headBucket(HeadBucketRequest.builder().bucket(bucketName).build()) != null;

Choose a reason for hiding this comment

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

@seratch San: Do you think that this implementation from the AWS is better than then using HeadBucketRequest

Copy link
Member Author

Choose a reason for hiding this comment

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

@acharyashashank Thanks for the suggestion!

I switched to headBucket because the AWS migration guide recommends using the API in version 2: https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration-service-changes.html. Do you think using getBucketAcl instead could bring benefits such as faster runtime performance?

Even if I use the code snippet provided there, I won't follow AwsServiceException error handling because the goal of this code is to verify if the client has permissions to fetch/modify S3 bucket data, rather than checking the bucket's existence.

Copy link
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

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

I'm a bit rusty on my java but this looks good to me 👍

Left once comment about error messages, but should not be a blocker

if (!bucketExists) {
throw new IllegalStateException("Failed to access the Amazon S3 bucket (name: " + bucketName + ")");
String message = "Failed to access the Amazon S3 bucket (name: " + bucketName + ", error: " + error + ")";
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this print out only the error message or the message with the stack trace?

Do we want to have the message of this error contain the trace of another error 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

This prints only this exception, but it depends on how toString method is implemented by an exception class. So, I've tweaked the code to have only the class name and message. Thanks for the suggestion!

@seratch seratch merged commit 26dba31 into slackapi:main Dec 6, 2024
6 checks passed
@seratch seratch deleted the issue-1402-aws-v2 branch December 6, 2024 00:14
@seratch seratch modified the milestones: 1.x, 1.45.0 Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement M-T: A feature request for new functionality project:bolt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrating AWS S3 SDK to v2
3 participants