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
Support Duration for expirationTime in Aws4PresignerParams #1040
Comments
I concur with @dhobbs, I just hit a similar issue right now when presigning URLs: software.amazon.awssdk.core.exception.SdkClientException: null
at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:97) ~[sdk-core-2.5.0.jar:?]
at org.broad.igv.util.S3Presigner.presignS3DownloadLink(S3Presigner.java:64) ~[main/:?]
at org.broad.igv.util.AmazonUtils.translateAmazonCloudURL(AmazonUtils.java:261) ~[main/:?]
at org.broad.igv.util.ResourceLocator.setPath(ResourceLocator.java:330) ~[main/:?]
at org.broad.igv.util.ResourceLocator.<init>(ResourceLocator.java:129) ~[main/:?]
at org.broad.igv.aws.S3LoadDialog.lambda$loadButtonActionPerformed$0(S3LoadDialog.java:114) ~[main/:?]
at org.broad.igv.util.LongRunningTask.call(LongRunningTask.java:72) [main/:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.time.DateTimeException: Instant exceeds minimum or maximum instant |
This goes deeper to Line 405 in 985ec92
It's weird (to me at least) that an Instant is used, but it's really treated as a duration. So it feels like the API is the worst of both worlds; giving the impression that expirationTime is an actual point-in-real-world-time due to it being an Instant but in reality it's used as a duration. |
The bug with |
@millems So this is just adding an alternate method to the builder and calculating |
@jeffalder Seems like that's about it. We'd probably want to go based on the Either way, we probably should validate that people aren't trying to set both, since that indicates a misunderstanding of the API that could manifest in weird ways if they both mutate the same configuration value. |
…91a8501b1 Pull request: release <- staging/e1139ad2-8082-433d-b4f7-a5e91a8501b1
Expected Behavior
When setting the expirationTime in the Aws4PresignerParams.Builder, it requires a value indicating
how many seconds the URI should be valid for. A clearer type to use to indicate a duration is java.time.Duration.
Current Behavior
Currently it uses java.time.Instant, which represents a single point in time, not a period of time. This makes the API confusing, as to specify eg. 1 hour expiry, the value
Instant.ofEpochSecond(60 * 60)
must be used. This value actually means a point in time of1970-01-01T01:00:00Z
. Using Instant implies to the caller that a point in time fromInstant.now()
should be specified, but this is interpreted as a very large expiration time and throws an exception.Possible Solution
Modify the API to take
Duration
objects instead ofInstant
.Steps to Reproduce (for bugs)
Call
.expirationTime(Instant.now())
onAws4PresignerParams.Builder
and try to create a presigned URI.Context
Your Environment
The text was updated successfully, but these errors were encountered: