Misleading zip error message for broken links #518

Open
jbuhacoff opened this Issue Jan 7, 2017 · 2 comments

Projects

None yet

2 participants

@jbuhacoff

I tried sdk install ant and got this output:

Downloading: ant 1.9.7

In progress...

######################################################################## 100.0%
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /home/Jonathan/.sdkman/archives/ant-1.9.7.zip or
        /home/Jonathan/.sdkman/archives/ant-1.9.7.zip.zip, and cannot find /home/Jonathan/.sdkman/archives/ant-1.9.7.zip.ZIP, period.

Stop! The archive was corrupt and has been removed! Please try installing again.

I looked up this message and found a number of old tickets about wrong version of zip. I'm using cygwin and I checked that I do have the zip and unzip packages from the archive category. I edited the sdkman-install.sh script to skip deleting the "corrupted" zip file and I found that what actually got downloaded was this:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /apache/ant/binaries/apache-ant-1.9.7-bin.zip was not found on this server.</p>
<hr>
<address>Apache/2.4.10 (Debian) Server at mirror.vorboss.net Port 80</address>
</body></html>

I checked the download URL with curl and got this output:

$ curl -L -I https://api.sdkman.io/2/broker/download/ant/1.9.7/cygwin_nt-10.0
HTTP/1.1 302 Found
Server: nginx/1.11.5
Date: Sat, 07 Jan 2017 04:02:12 GMT
Content-Length: 0
Connection: keep-alive
location: http://mirror.vorboss.net/apache/ant/binaries/apache-ant-1.9.7-bin.zip

HTTP/1.1 404 Not Found
Date: Sat, 07 Jan 2017 04:02:13 GMT
Server: Apache/2.4.10 (Debian)
Content-Type: text/html; charset=iso-8859-1

So it appears the root cause of my issue is that the broker is redirecting to a URL that doesn't have the requested package, and the zip error is shown because what got downloaded from the server is some HTML instead of a zip file.

I made a couple of changes in sdkman-util.sh and sdkman-install.sh to detect the HTTP error and produce a more accurate message.

@jbuhacoff
jbuhacoff commented Jan 7, 2017 edited

Please see my pull request #519 for the changes.

Now I get output like this, which accurately describes what happened:

$ sdk install ant

Downloading: ant 1.9.7

In progress...

######################################################################## 100.0%

Failed to download ant from https://api.sdkman.io/2/broker/download/ant/1.9.7/cygwin_nt-10.0
@marc0der
Member
marc0der commented Jan 7, 2017

Thanks for reporting this. Comments left in PR.

@marc0der marc0der changed the title from misleading zip error message for broken links to Misleading zip error message for broken links Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment