Fix: Can't regenerate failed/expired ZIMs (#1036)#1059
Fix: Can't regenerate failed/expired ZIMs (#1036)#1059audiodude merged 3 commits intoopenzim:mainfrom
Conversation
|
I don't have time to review the code right now, I only read the description. But I wanted to leave immediate feedback to tell you that, based on your description, I really appreciate the problem solving and effort that went into this PR. And I apologize for the state of the code that caused this bug. I am interested in how the tests passed for this deficient code, but I expect that they were also deficient in the sense that they were testing the incorrect behavior instead of the behavior we actually desired. Please make sure to run and update tests as necessary. Again, thank you so much! I will review this soon. |
audiodude
left a comment
There was a problem hiding this comment.
This logic seems sound, so good work. All that's left is to add tests for the 3 new cases (selection version has changed, new zim_task id required, update b_selection_zim_version).
While you're in there, check if the existing tests are even still useful, and be sure to delete or amend as necessary.
Thanks!
Apologies for the delay on this; I was unavailable last week. I've added the tests now, and they cover all the cases as requested. I checked the codebase for existing or related tests to reference but couldn't find any, so I implemented these to ensure full coverage of the new logic. |
audiodude
left a comment
There was a problem hiding this comment.
Okay holidays are over, back to work 😭
This looks good, just needs a few refactors to tests. Thanks!
Welcome back, hope you had a great holiday 😊 |
audiodude
left a comment
There was a problem hiding this comment.
This is great! The tests look so much better, thanks. I will run the CI and merge now if it passes.
Congratulations on your first WP1 patch! You are officially a WP1/Wikipedia/Kiwix contributor! 🎉
e3d3473 to
a0fc865
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1059 +/- ##
==========================================
- Coverage 92.84% 92.83% -0.01%
==========================================
Files 74 74
Lines 4317 4325 +8
==========================================
+ Hits 4008 4015 +7
- Misses 309 310 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The bug had some minor issues :
Schedule existence check was using the wrong ID (s_id instead of builder_id) causing the code to think schedules didn't exist when they actually did , This led to 409 Conflict errors when trying to create "new" schedules
after fixing the ID issue , I hit a 405 Method Not Allowed error because the PATCH request was going to /v2/schedules instead of /v2/schedules/{schedule_name} . I have investigated The Zimfarm API requires the schedule name in the URL path
after fixing both API issues the request was made and the ZIM was created but download URLs were still broken because the task_id wasn't being updated properly when selection versions changed, and the version pointer (b_selection_zim_version) still pointed to the old selection
Changes made:
zimfarm.py : Use builder_id instead of s_id for schedule checks, and fix PATCH URL to include schedule name in the path
builder.py: Add three layer update logic (try current selection - - > try by schedule_id --> insert new) and update b_selection_zim_version to point to current selection when requesting ZIMs
I have tested this locally , by reproducing the same issue , it worked fine , i have successfully regenerated the failed ZIMs and verified the download links works fine
I tried to explain the issue well , please review it , maybe I found the causes of the issue , but actually I'm not sure if this is the correct way to solve it
fixes #1036