fix: handle expired ZIM downloads with user-friendly error#1090
fix: handle expired ZIM downloads with user-friendly error#1090audiodude merged 2 commits intoopenzim:mainfrom
Conversation
|
Hello @audiodude, I hope you see this PR This happens mainly because I found that there is a getStatus() function in the ZimFile.vue and this function only evaluates the expiration based on time only, not the head request so updating the If you want I can refactor the whole solution to apply this approach. But if you seek a front-end friendly solution only I guess that's works Edit:
I agree with you this seems to be logical but we can't do this without massive overhead because we will need to send head request everytime the |
audiodude
left a comment
There was a problem hiding this comment.
This looks really good! This is the appropriate approach that I've been looking for, checking the status on the server at the time of the ZIM request. I also like the idea of reusing the expired message on the ZIM page, because it has the benefit of letting the user immediately request a new ZIM.
Just one small change requested.
8395f5c to
418f3ca
Compare
d4d9deb to
22e0db2
Compare
|
Hello @audiodude I have submitted the fix now based on your latest review, kindly review, Thank You! |
fbac640 to
f327eab
Compare
f327eab to
8741969
Compare
audiodude
left a comment
There was a problem hiding this comment.
Tests are failing: https://github.com/openzim/wp1/actions/runs/22513369359/job/65226917959?pr=1090
Please fix.
|
@audiodude Hello, Thanks for the review, I will figure out the tests issue today |
|
@Best2Two Could you also please file a follow up issue for yourself to clean up this data (https://github.com/openzim/wp1/blob/main/wp1/logic/builder.py#L851-L854), the function it calls, and the frontend functionality that depends on it? Thanks! |
|
@audiodude I opened the issue, Now I am fixing the tests that I forgot to update |
|
@audiodude Hello, I have fixed the tests, now I assume they will pass, kindly can you please rerun CI/CD checks! |
|
Hello @audiodude quick ping, kindly can you review the last changes to make sure if there is something else needs to be modified |
Yes, everyone always assumes their tests will pass, no one intentionally writes broken code.... 😂 But we don't have to assume. We can run the tests ourselves. Are you having trouble running |
|
@audiodude I mean I assume they will pass so rerun the ci/cd to test, not merge before testing!😂 they have passed locally after running |
|
Hello @audiodude , I have ran all of the tests and they all had been passed. Kindly can you check. Thanks |
|
@audiodude Hello, quick ping can you run the CI/CD please? Thanks |
56acc72 to
e0a28f9
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1090 +/- ##
=======================================
Coverage 92.78% 92.78%
=======================================
Files 74 74
Lines 4308 4312 +4
=======================================
+ Hits 3997 4001 +4
Misses 311 311 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|

I hope those PRs do something with GSoC :)
Reproduction:
I can see that latest_zim_file_for_builder generates the url based on the latest url for the zim using the function latest_zim_file_url_for, checking that method it calls zim_file_url_for_task_id
so by injecting a bad url like that
def zim_file_url_for_task_id(task_id):
return "https://s3.us-east-1.wasabisys.com/org-kiwix-wikimedia/FAKE_EXPIRED.zim"
and inserting the required records into the tables zim_tasks, selections and builders to simulate a valid selection to prevent Error 404 for my bad fake url and reproduce the targeted error. I managed to reproduce it correctly the same issue as the issuer and I can see it both in the front end and the back end!
Fixes #825
prefetching the wasabi URL with requests, with a HEAD request.
The approach was making head request inside the latest_zim_file_for_builder if it return 404 then it redirects user to create new ZIM.