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

S3Presigner.Builder returns SdkPresigner #4604

Closed
KevinAtSesam opened this issue Oct 17, 2023 · 6 comments · Fixed by #4606
Closed

S3Presigner.Builder returns SdkPresigner #4604

KevinAtSesam opened this issue Oct 17, 2023 · 6 comments · Fixed by #4606
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@KevinAtSesam
Copy link

Describe the bug

Take this Scala 2.13 code:

 private def getAwsS3PreSigner(config: Config): S3Presigner = {
    val awsAccessKeyId = config.getString("aws.iam.accessKey.id")
    val awsSecretKey   = config.getString("aws.iam.accessKey.secret")
    val regionName     = config.getString("aws.region")

    val awsCredentials: AwsBasicCredentials = AwsBasicCredentials.create(awsAccessKeyId, awsSecretKey)
    val region                              = Region.of(regionName)

    S3Presigner
      .builder()
      .region(region)
      .credentialsProvider(StaticCredentialsProvider.create(awsCredentials))
      .build()
  }

With AWS SDK 2.20.162, this compiles properly. With AWS SDK 2.21.1 this doesn't compile, causing a typing error:

[error] [..]/Main.scala:431:13: type mismatch;
[error]  found   : software.amazon.awssdk.awscore.presigner.SdkPresigner
[error]  required: software.amazon.awssdk.services.s3.presigner.S3Presigner
[error]       .build()
[error]             ^

Expected Behavior

I expect that 2.21.1 is backwards compatible with 2.20.162 and that the builder returns the proper implementation. This is likely caused by .region() and/or .credentialsProvider() because without those two statements, it does still compile properly.

Current Behavior

Compile-error because the wrong type is returned by .build(). Do mind, that other SdkBuilder instances like SNS or CloudWatch all compile as expected.

Reproduction Steps

Feel free to take the code from above. My apologies for giving you this example in Scala 2.13

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

2.21.1

JDK version used

OpenJDK Runtime Environment Corretto-21.0.0.35.1 (build 21+35-LTS)

Operating System and version

Fedora Linux 38

@KevinAtSesam KevinAtSesam added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 17, 2023
@debora-ito
Copy link
Member

@KevinAtSesam I'll move this to the Java SDK v2 repository.

@debora-ito debora-ito transferred this issue from aws/aws-sdk-java Oct 17, 2023
@sugmanue
Copy link
Contributor

@KevinAtSesam I cannot reproduce the issue using Java, do you have a self contained example that we can use to reproduce? In particular I would be interested in the dependencies that you are using.

For what's worth I tested using this Java class

package software.amazon.awssdk.test;

import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.presigner.S3Presigner;

public class App {
    public static S3Presigner getAwsS3PreSigner() {
        AwsBasicCredentials awsCredentials = AwsBasicCredentials.create("foo", "bar");
        return S3Presigner
                .builder()
                .region(Region.ME_SOUTH_1)
                .credentialsProvider(StaticCredentialsProvider.create(awsCredentials))
                .build();
    }
}

And these dependencies in the pom.xml file

  <dependencies>    
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>s3</artifactId>
      <version>2.21.1</version>
    </dependency>
  </dependencies>

@debora-ito debora-ito added p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Oct 17, 2023
@debora-ito debora-ito self-assigned this Oct 17, 2023
@debora-ito debora-ito added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. label Oct 17, 2023
@debora-ito
Copy link
Member

Just to complement @sugmanue comment, our guess is that you are using a version of core that is different than 2.21.1. All SDK modules should be in the same version, otherwise you can run into some weird errors.

You can check this by printing your dependency tree, in maven the command is

> mvn dependency:tree

@debora-ito debora-ito added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. labels Oct 17, 2023
@sugmanue
Copy link
Contributor

@KevinAtSesam we were able to reproduce the issue with a local Scala project. Looks like a bug in the Scala compiler that does not like how we are defining our interfaces in Java. Regardless we have a fix for it in #4606 which is under review by the team and does the trick for us.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. label Oct 18, 2023
@sugmanue
Copy link
Contributor

I have added a comment to this similar issue open in the Scala repository with a small test case to reproduce the bug.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants