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

[JENKINS-73381] Downloading tar.gz artifacts in Firefox is broken #397

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

basil
Copy link
Member

@basil basil commented Jul 1, 2024

Problem

When downloading tar.gz artifacts with Firefox, which sets Accept-Encoding: gzip, deflate, br, zstd, the downloaded file is broken and has a different size than when downloaded with other browsers like Edge or Chrome.

Evaluation

GzipHandler incorrectly kicks in, double-gzipping the file. Normally GzipHandler ignores the application/gzip MIME type, but we were incorrectly sending the MIME type application/x-gtar.

Solution

Send the correct MIME type by bringing mime.properties closer to upstream Jetty. Note that the explicit tar.gz mapping is only needed for Jetty 10 and must be removed pending the adoption of jetty/jetty.project#8919.

Testing done

  • Reproduced the issue as described in the ticket on Firefox. Also confirmed the issue was not visible on Chrome. After this PR, both Firefox and Chrome work.
  • Added new unit test that fails before this PR and passes after.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@basil basil added the bug label Jul 1, 2024
@basil basil merged commit f15766d into jenkinsci:master Jul 1, 2024
15 checks passed
@basil basil deleted the JENKINS-73381 branch July 1, 2024 19:26
@@ -776,7 +778,7 @@ texinfo=application/x-texinfo
text=text/plain
tfi=application/thraud+xml
tfm=application/x-tex-tfm
tgz=application/x-gzip
tgz=application/x-gtar

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't tgz have the same mime type as tar.gz?

Now I have different sizes when downloading a file as .tar.gz than when downloading it as .tgz

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not doing anything different from upstream Jetty here:

https://github.com/jetty/jetty.project/blob/jetty-12.0.x/jetty-core/jetty-http/src/main/resources/org/eclipse/jetty/http/mime.properties#L163

If there is a bug here, please report it to the upstream Jetty project and then we will pull it in automatically as part of a future Jetty upgrade.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, I had the same idea, however after further evaluation, instead of having the developers
hardcoding custom mimetypes, I found an easier way to fix arbitrary
custom mimetypes: Just add --mimeTypes=tgz=application/gzip to the jenkins commandline.
When using systemd, you can specify any additional cmdline options for jenkins by specifying the
following in your jenkins override file:
Environment="JENKINS_OPTS=--mimeTypes=tgz=application/gzip"
This fixed download of .tgz artifacts for me.

Just my 2cent

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felfert thank your for this workaround as well.
For others who may stumble across this issue when searching for the problem:
Basil has since reported the issue to jetty himself and it's already fixed in jetty.
Here's a jenkins issue for the problem. The fix will eventually make its way into jenkins. Fortunately there are also workarounds like the suggestion from @felfert until then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants