## Implementation Plan: Fix Zip Service 100% Failure Rate ### Changes Required 1. **Apply the three blob‑resilience fixes to `master`** (if not already present). The complete fix is on branch `typosaurus/ticket-68`. - Either merge that branch into `master` or cherry‑pick the commits/apply the diffs. - In `project_files.py` (locate via `grep -r "def export_to_dir"`) ensure: - **`export_to_dir`** – wrap each `shutil.copyfile(src, dst)` in `try/except (FileNotFoundError, OSError)`, log a warning, and `continue` (around current master line 710). - **`_export_node`** – same wrapper around `shutil.copyfile` (around master line 580). - **`delete_node`** – after the soft‑delete loop, iterate over binary nodes and call `_unlink_blob(row)` (around master line 466). - **`export_to_dir`** – confirm no call to `_guard_writable(project_uid)` remains (around master line 687). *Exact line numbers may shift if intervening commits exist; verify by inspecting the diff.* 2. **Add missing test coverage for the blob‑missing scenario.** In `tests/unit/services/jobs/zip_service.py`: - Create a test method, e.g. `test_zip_job_with_missing_blob_succeeds`. - Set up a project containing a binary file whose DB row exists but blob file is deleted from disk. - Enqueue a zip job and assert it completes with `status == "done"` and `bytes_out > 0`. - Confirm the resulting archive does not contain the missing file (log warning is sufficient; the test should not raise). 3. **Run verification commands.** In a Python ≥3.12 environment: ```bash python3 -m venv .venv && source .venv/bin/activate pip install -e '.[dev]' -q make test-unit pip install -q ruff && ruff check . ``` ### Definition of Done - [ ] `git diff master..HEAD -- devplacepy/routers/projects/project_files.py` (or the correct path) shows exactly the three changes described above – no extra modifications. - [ ] New test `test_zip_job_with_missing_blob_succeeds` exists in `tests/unit/services/jobs/zip_service.py` and can be identified by grep. - [ ] Virtual environment created, dependencies installed without errors. - [ ] `make test-unit` exits with exit code 0; the new test passes alongside all existing tests. - [ ] `ruff check .` exits with exit code 0 (no lint errors on any file). - [ ] Working tree is clean (no merge conflicts, no uncommitted changes unrelated to the fix).