ZIP endpoints don't raise errors
iansedano opened this issue · comments
Queries that end up trying to download the ZIP directly don't raise an error when they fail.
https://github.com/rahmonov/alcazar
https://github.com/realpython/dockerizing-django/archive/master.zip
The first type of query gets archive/master.zip
added onto the end of it, and the second type just gets passed through to the download stage.
To download this ZIP, the code currently opens an invisible I-Frame, which works until you pass in an invalid URL.
https://github.com/rahmonov/alcazarrrrrrrrrr
https://github.com/realpython/dockerizing-djanggggggggggo/archive/master.zip
In which case the I-Frame returns a 404, but since it's in an I-Frame, it can't communicate this to the context in which the JS is running in.
I opted for the I-Frame method because it would cut down on requests to the API, but just for graceful error handling, it probably makes sense to change this.
That seems to leave us with three options:
- Convert all queries, including
.zip
ones to calls to the API. Yet that might run the risk of running into the quota if the repository is particularly large (i.e. over 60 sub-folders which means over 60 requests). - Redirect and open up a new tab. However, the buttons would still be broken in
index.html
if we did that. - Present a link for them to click to download.
3 might be the best and simplest option here.
In the end I opted for option 1 because even with presenting a link to download, if the URL is wrong, the UX isn't great because it will just take you to a page that says "Not Found".
See #8