[PR #424] [CLOSED] fix(setup): drop an engine archive that fails to unpack #2634

Closed
opened 2026-11-04 02:01:57 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/424
Author: @alphastorm
Created: 10/1/2026
Status: ❌ Closed

Base: main ← Head: fix/unreadable-engine-archive


📝 Commits (1)

  • 0d844d1 fix(setup): drop an engine archive that fails to unpack

📊 Changes

2 files changed (+21 additions, -2 deletions)

View changed files

📝 setup.py (+6 -2)
📝 tools/test_setup_pins.py (+15 -0)

📄 Description

Follow-up to #399, which was closed as covered by 0.1.32. 0.1.32's drop_archive does cover #397's refused archives. One case from #399 is still open at aeb35be (0.1.33): an archive that fails to unpack.

When the downloaded engine archive is not a zip, or is a damaged one, get_prebuilt raises BadZipFile but keeps engine/<asset> and its .done mark. download() trusts the mark, so every later run prints "Strata engine already downloaded" and fails on the same file. This goes on after the right archive is published, until someone deletes the file by hand. On the update path the caller catches the error ("updating the engine failed (File is not a zip file)") and starts the installed engine, so the engine is never updated.

Change

  • setup.py (get_prebuilt): on zipfile.BadZipFile from unpacking, the archive and its mark are dropped (drop_archive), and the error propagates as before. An OSError while unpacking (a full disk, a path that is too long) still keeps the archive, because downloading it again would not help.

Behavior changes

  • The run that meets the bad archive fails as before (BadZipFile). The next run downloads the archive again instead of failing on the same file.

Tests (python -m unittest tools.test_setup_pins, no network)

  • Engine.test_an_archive_that_does_not_unpack_is_not_kept runs get_prebuilt with the real download() over a --prebuilt folder. The folder first holds a file that is not a zip, then the right archive. On aeb35be the second run raises BadZipFile again. With the change, the second run installs the engine.
  • I ran every Python test module (serve/test_*.py, tools/test_*.py: 27 modules, 346 tests, 9 skipped) with and without the change, with STRATA_GGUF_PY set for tools.test_iq_pack. The results are the same, except for the new test, which errors without the change. tools.test_setup_golden fails the same 46 subtests in both runs. The cause is on non-Windows hosts: there EXE is strata, so the test's path normalization also turns the log name strata-<quant>.log into <EXE>-<quant>.log. These runs used Python 3.13.15 on macOS arm64. ruff and pyright report nothing new in the changed files.

Also checked

  • The update path over a local HTTP server standing in for GitHub releases (PREBUILT_URL and PREBUILT_TAG_URL patched, real download()). The release first serves an HTML page, then the right archive. On aeb35be, every run after the first sends one HEAD, prints "Strata engine already downloaded" and fails with BadZipFile. With the change, the next run downloads and installs the engine, and the run after that sends no request.

Not run: Windows, a GPU, or a real release download.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/424 **Author:** [@alphastorm](https://github.com/alphastorm) **Created:** 10/1/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/unreadable-engine-archive` --- ### 📝 Commits (1) - [`0d844d1`](https://github.com/Niko1221/Strata/commit/0d844d184c5953527d681dbf5545ade4fba86e34) fix(setup): drop an engine archive that fails to unpack ### 📊 Changes **2 files changed** (+21 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `setup.py` (+6 -2) 📝 `tools/test_setup_pins.py` (+15 -0) </details> ### 📄 Description Follow-up to #399, which was closed as covered by 0.1.32. 0.1.32's `drop_archive` does cover #397's refused archives. One case from #399 is still open at `aeb35be` (0.1.33): an archive that fails to unpack. When the downloaded engine archive is not a zip, or is a damaged one, `get_prebuilt` raises `BadZipFile` but keeps `engine/<asset>` and its `.done` mark. `download()` trusts the mark, so every later run prints "Strata engine already downloaded" and fails on the same file. This goes on after the right archive is published, until someone deletes the file by hand. On the update path the caller catches the error ("updating the engine failed (File is not a zip file)") and starts the installed engine, so the engine is never updated. **Change** - `setup.py` (`get_prebuilt`): on `zipfile.BadZipFile` from unpacking, the archive and its mark are dropped (`drop_archive`), and the error propagates as before. An `OSError` while unpacking (a full disk, a path that is too long) still keeps the archive, because downloading it again would not help. **Behavior changes** - The run that meets the bad archive fails as before (`BadZipFile`). The next run downloads the archive again instead of failing on the same file. **Tests** (`python -m unittest tools.test_setup_pins`, no network) - `Engine.test_an_archive_that_does_not_unpack_is_not_kept` runs `get_prebuilt` with the real `download()` over a `--prebuilt` folder. The folder first holds a file that is not a zip, then the right archive. On `aeb35be` the second run raises `BadZipFile` again. With the change, the second run installs the engine. - I ran every Python test module (`serve/test_*.py`, `tools/test_*.py`: 27 modules, 346 tests, 9 skipped) with and without the change, with `STRATA_GGUF_PY` set for `tools.test_iq_pack`. The results are the same, except for the new test, which errors without the change. `tools.test_setup_golden` fails the same 46 subtests in both runs. The cause is on non-Windows hosts: there `EXE` is `strata`, so the test's path normalization also turns the log name `strata-<quant>.log` into `<EXE>-<quant>.log`. These runs used Python 3.13.15 on macOS arm64. ruff and pyright report nothing new in the changed files. **Also checked** - The update path over a local HTTP server standing in for GitHub releases (`PREBUILT_URL` and `PREBUILT_TAG_URL` patched, real `download()`). The release first serves an HTML page, then the right archive. On `aeb35be`, every run after the first sends one `HEAD`, prints "Strata engine already downloaded" and fails with `BadZipFile`. With the change, the next run downloads and installs the engine, and the run after that sends no request. Not run: Windows, a GPU, or a real release download. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:01:57 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2634
No description provided.