mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1797] setup.py get_llama_cpp(): a truncated llama.cpp zip is marked done, then fails with BadZipFile on every rerun #715
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#715
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @agnaylor on GitHub (Oct 10, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1797
Environment
xe)-DSTRATA_SYCL_AOT=bmg-g31fb58e0d(v0.1.41)Summary. There are three problems that add up:
Content-Length. On 2026-10-09 a HEAD request toLLAMA_CPP_ZIP(
setup.py:167) got a 302 withContent-Length: 0and then a 200 with no length, sototal == 0indownload()(
setup.py:1338-1340).total == 0,download()takes a stream that ends early as complete. The loop stops at the first clean endof stream (
setup.py:1385,if not total or have >= total: break), the final size check is skipped(
setup.py:1391,if total and ...), and the file gets its.donemark (setup.py:1401).get_llama_cpp()(setup.py:1563-1593) opens the zip with no validation (:1572) and deletes the zip and its.donemark only on success (:1591-1592). After aBadZipFile, the next run sees.done(setup.py:1317),skips the download, and fails again. Recovery means deleting
third_party/llama.cpp-3cf0325.zip{,.done}by hand.Repro (deterministic, without needing a slow link)
In the wild: run setup while another process saturates the link, so the codeload stream closes early.
Expected: setup notices the bad archive, deletes it and its mark, downloads it again (with a few retries), and
only fails with a clear message if it stays bad.
Actual: a
zipfile.BadZipFile: File is not a zip filetraceback, and the same traceback on every later run.Suggested fix
Pin the archive's SHA-256 next to
LLAMA_CPP_COMMIT(setup.py:166-167) and check it with the existingverify_sha256()(setup.py:1490) before marking it done. Or, at minimum, havedownload()check for a knowntype when
total == 0(for zips:zipfile.is_zipfile()/ZipFile.testzip()).Related, and the fix already exists one function over: #424 reported the same sticky
BadZipFilefor theengine archive. 0.1.40 fixed it with
drop_archive()(setup.py:1306), called fromget_prebuilt'sexcept zipfile.BadZipFile:(setup.py:2858).get_llama_cpp()never got that change. Open PR #1126 rewritesthese exact lines (
get_llama_cppnow calls a newsafe_extract()) but does not add the drop, so it does notfix this. Coordinate with it rather than conflicting.
Minimum fix (same as #424): in
get_llama_cpp(),except zipfile.BadZipFile: drop_archive(z); raise. The nextrun then downloads again.
Better, wrap the extraction with a retry:
Separately:
download()catchesOSErroronly (setup.py:1387). When a chunked stream is cut off mid-chunk,http.client.IncompleteReadis raised, which is anHTTPException, not anOSError, so the 30-try retry loopdoes not cover it. Add
http.client.HTTPExceptionto thatexcept.@Niko1221 commented on GitHub (Oct 10, 2026):
Fixed in v0.1.42 by #1801 (setup drops a damaged llama.cpp source archive and its .done mark when it cannot be unpacked, so the next run fetches it again).