molgenis / molgenis-emx2

MOLGENIS EMX2, the latest version of the MOLGENIS data platform.
GNU Lesser General Public License v3.0
11 stars 16 forks source link

When downloading a zip file from the tables or Up/Download page the file is downloaded without the schema name #1211

Closed marijevdgeest closed 10 months ago

marijevdgeest commented 2 years ago

What version of EMX2 are you using (see footer) 8.66.0

Describe the bug When you go to the tables page in a database and click on the 'download all tables zip' link, you get a file with the schema name, but sometimes the file is downloaded with the name 'zip.zip'. Unclear when this happens.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'https://emx2.dev.molgenis.org'
  2. Click on a schema
  3. Navigate to 'tables'
  4. Click download all tables 'zip'
  5. Do this multiple times, sometimes file with schema name is downloaded, sometimes not.

Expected behavior Download of zip file with schema name

mswertz commented 1 year ago

Unless we find a good example (please record the name of the schema) we can't fix this one.

marijevdgeest commented 1 year ago

Unless we find a good example (please record the name of the schema) we can't fix this one.

For me it's all schemas, for example in the data-catalogue-staging ALSPAC schema. Click 'zip' here: https://data-catalogue-staging.molgeniscloud.org/ALSPAC/tables/#/ I get a zip.zip

mswertz commented 1 year ago

@marijevdgeest what browser do you use? Might this be the firefox issue reported at #886 ?

clemens-tolboom commented 10 months ago

There is a weird difference between

and

curl

Checking for the headers it seems our intended headers disappeared compared to my local dev server.

< Content-Type: application/zip
< Content-Disposition: attachment; filename=pet store1693833970394.zip

emx2.dev.molgenis.org

curl -vvvvvv  https://emx2.dev.molgenis.org/catalogue/api/zip
*   Trying 129.125.2.100:443...
* Connected to emx2.dev.molgenis.org (129.125.2.100) port 443 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-AES128-GCM-SHA256
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  subject: C=NL; ST=Groningen; O=Rijksuniversiteit Groningen; CN=*.dev.molgenis.org
*  start date: Jun 26 00:00:00 2023 GMT
*  expire date: Jun 25 23:59:59 2024 GMT
*  subjectAltName: host "emx2.dev.molgenis.org" matched cert's "*.dev.molgenis.org"
*  issuer: C=NL; O=GEANT Vereniging; CN=GEANT OV RSA CA 4
*  SSL certificate verify ok.
* using HTTP/1.x
> GET /catalogue/api/zip HTTP/1.1
> Host: emx2.dev.molgenis.org
> User-Agent: curl/8.1.2
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Mon, 04 Sep 2023 14:31:03 GMT
< Transfer-Encoding: chunked
< Connection: keep-alive
< Set-Cookie: JSESSIONID=node019suvuw9vehf6m4nv5xkp51zx40.node0; Path=/; Secure; HttpOnly
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Strict-Transport-Security: max-age=15724800; includeSubDomains
< Set-Cookie: BIGipServerwebhost_pool_gcc_https=2084612288.47873.0000; path=/; Httponly; Secure
< 

Dev

curl -vvvvvv http://localhost:8080/pet%20store/api/zip
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /pet%20store/api/zip HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.1.2
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Mon, 04 Sep 2023 13:26:10 GMT
< Set-Cookie: JSESSIONID=node01nwuwffjlxmv6sypkdm0v86mj5.node0; Path=/; HttpOnly
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Content-Type: application/zip
< Content-Disposition: attachment; filename=pet store1693833970394.zip
< Content-Length: 2466
< Server: Jetty(9.4.48.v20220622)
clemens-tolboom commented 10 months ago

?

On https://data-catalogue-acc.molgeniscloud.org

Pet store OK others WRONG

On https://data-catalogue.molgeniscloud.org

All WRONG

On https://emx2.dev.molgenis.org

Pet store OK

On http://localhost:8080

clemens-tolboom commented 10 months ago

Debugging it seems code reacts different on different :schema

  protected static boolean schemaExists(DSLContext jooq, String name) {
    return jooq.selectFrom(SCHEMA_METADATA).where(TABLE_SCHEMA.eq(name)).fetch().isNotEmpty();
  }

Debugging has a side effect that browser can catchup with its data so we concluded code order matters:

clemens-tolboom commented 10 months ago

Probably effects more files in backend/molgenis-emx2-webapi/src/main/java/org/molgenis/emx2/web/

ack -i -B 4 -A 4 stream.write backend/molgenis-emx2-webapi/src/main/java/org/molgenis/emx2/web