ConservationColorado / asana-hire

A lightweight recruitment management web application!
GNU General Public License v3.0
3 stars 0 forks source link

403 Forbidden on long running attachment processes #24

Open OliverAbdulrahim opened 1 year ago

OliverAbdulrahim commented 1 year ago

Observed issue

Attempting to download an attachment will fail with HTTP 403 Forbidden if around 120 seconds has elapsed (that's my best guess) after acquiring the download URL.

Scope

Task attachment does not download. See the documentation for this endpoint.

Possible solution

  1. Find a less transient attachment download URL
  2. Download the attachment and store it server-side rather than relying on the link
  3. Avoid long queues of attachment downloads

Stack trace

java.io.IOException: Server returned HTTP response code: 403 for URL: https://asana-user-private-us-east-1.s3.amazonaws.com/assets/<redacted>

Original Stack Trace:
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1980) ~[na:na]
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1581) ~[na:na]
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224) ~[na:na]
    at java.base/java.net.URL.openStream(URL.java:1317) ~[na:na]
    at org.conservationco.asana.extensions.tasks.Tasks.createAttachment(Tasks.kt:53) ~[kotlin-asana-39de515f38.jar:na]
    at org.conservationco.asana.extensions.AsanaClientExtension.createAttachment(AsanaClientExtension.kt:79) ~[kotlin-asana-39de515f38.jar:na]
    at org.conservationco.asana.extensions.AsanaClientExtension.createTask(AsanaClientExtension.kt:138) ~[kotlin-asana-39de515f38.jar:na]
    at org.conservationco.asanahire.service.SyncService.addToInterviewProject(SyncService.kt:132) ~[classes/:na]
    at org.conservationco.asanahire.service.SyncService.syncSingleApplicant(SyncService.kt:113) ~[classes/:na]
    at org.conservationco.asanahire.service.SyncService.access$syncSingleApplicant(SyncService.kt:22) ~[classes/:na]
    at org.conservationco.asanahire.service.SyncService$startSync$2.invoke(SyncService.kt:94) ~[classes/:na]
    at org.conservationco.asanahire.service.SyncService$startSync$2.invoke(SyncService.kt:94) ~[classes/:na]
    at org.conservationco.asanahire.service.SyncService.startSync$lambda$10(SyncService.kt:94) ~[classes/:na]
OliverAbdulrahim commented 1 year ago
  1. Create a pivot_index column for each job (essentially just the size of that project at the time)
  2. Create a last_run column for each job
  3. Fall back to a full sync only if there's no last_run