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

Publishing to S3 URL fails with java.lang.IllegalArgumentException: No region provided #5

Closed
aecollver opened this issue Aug 28, 2014 · 5 comments

Comments

@aecollver
Copy link

This is the URL I'm using (I've tried the variations listed in the README.md):

s3://s3-us-west-2.amazonaws.com/repo.munchii.com/snapshots

And this is the exception I see:

java.lang.IllegalArgumentException: No region provided
at com.amazonaws.AmazonWebServiceClient.setRegion(AmazonWebServiceClient.java:356)
at com.amazonaws.services.s3.AmazonS3Client.setRegion(AmazonS3Client.java:503)
at fm.sbt.S3URLHandler$$anonfun$getClientBucketAndKey$1.apply(S3URLHandler.scala:118)
at fm.sbt.S3URLHandler$$anonfun$getClientBucketAndKey$1.apply(S3URLHandler.scala:118)
at scala.Option.foreach(Option.scala:236)
at fm.sbt.S3URLHandler.getClientBucketAndKey(S3URLHandler.scala:118)
at fm.sbt.S3URLHandler.getURLInfo(S3URLHandler.scala:126)
at fm.sbt.S3URLHandler.getURLInfo(S3URLHandler.scala:80)

I haven't had a chance to dig too deep, but I wonder if it might be related to this commit where AmazonS3URI now treats URLs that begin with s3:// differently:

aws/aws-sdk-java@1d8722f#diff-53c1eb1cf3afbc306872e09dbd33ec7f

tpunder added a commit that referenced this issue Aug 28, 2014
We try 3 different methods:

1. Parsing directly out of the URL that is being used (this seemed broken for s3:// URLs)
2. Doing a DNS lookup of <bucket>.s3.amazonaws.com and then reversing the resulting IP to see if it has a region in it.  I think this was working at one point but they seem to be using different hostnames now so I'm now trying to regex extract the region.
3. Using the AmazonS3Client.getBucketLocation call to determine the region.  This only works if the AWS credentials have access to the getBucketLocation call which is why it's last.
@tpunder
Copy link
Owner

tpunder commented Aug 28, 2014

I've attempted to fix this. Looks like there were multiple issues with the region detection code. The resulting code is a little messy and could use some simplification but it appears to be working now.

I've published the fix under the 0.4.0-SNAPSHOT version. Can you try with that version and see if it works?

In your plugins.sbt file:

resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
addSbtPlugin("com.frugalmechanic" % "fm-sbt-s3-resolver" % "0.4.0-SNAPSHOT")

@aecollver
Copy link
Author

I successfully tested the fix with the following URL formats:

s3://repo.munchii.com/snapshots
s3://s3.amazonaws.com/repo.munchii.com/snapshots
s3://repo.munchii.com.s3.amazonaws.com/snapshots
s3://s3-us-west-2.amazonaws.com/repo.munchii.com/snapshots
s3://repo.munchii.com.s3-s3-us-west-2.amazonaws.com/snapshots

@tpunder
Copy link
Owner

tpunder commented Aug 28, 2014

Great! I'll get that published to Maven Central as 0.4.0

@tpunder
Copy link
Owner

tpunder commented Aug 28, 2014

@aecollver
Copy link
Author

Thanks - I was able to successfully upgrade to 0.4.0.

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

No branches or pull requests

2 participants