[Bug]: v0.9.0 hard-codes a 512 MiB decompressed-image cap — large multi-page PDFs that v0.8.3 parsed now fail entirely, no env override
[Bug]: v0.9.0 adds a hard-coded 512 MiB decompressed-image cap that rejects large multi-page PDFs v0.8.3 parsed fine — no env override, whole document fails
Summary
v0.9.0 introduced maxZipImagesTotalBytes = 512 << 20 in internal/infrastructure/docparser/zip_limits.go. Any MinerU result package whose extracted images total more than 512 MiB is now rejected, and the whole document fails — no text chunks, no images, no partial result.
v0.8.3 had no such cap. On 0.8.3 the same 524-page document (1.03 GiB of page images) parsed and indexed successfully. Two of our large construction-drawing volumes now cannot be re-parsed at all on 0.9.0.
The constant is hard-coded with no environment variable, so the only workarounds are recompiling the app image or degrading render quality upstream.
Environment
- WeKnora v0.9.0 (upgraded from v0.8.3; schema 118 → 134, migration clean)
- Self-hosted MinerU engine via
parser_engine_overrides.mineru_endpoint(a custom adapter on MinerU 4.0,tier=advanced) RETRIEVE_DRIVER=qdrant, images stored in MinIO- Page images rendered upstream at 250 DPI, PNG lossless (this is our production setting; the adapter hands WeKnora a result zip whose
images/members total the figures below)
Steps to reproduce
- Prepare a multi-page PDF whose 250-DPI PNG page images total more than 512 MiB. Our measured samples:
- 540 pages →
images/total 658,308,530 B (628 MB) - 524 pages →
images/total 1,107,628,027 B (1.03 GiB)
- 540 pages →
- Upload it to a knowledge base configured with
parser_engine_rules= self-hosted MinerU (mineru_endpointset,mineru_tier=advanced). - Wait for parsing.
Actual result
Parsing fails as a whole. The error path is:
// internal/infrastructure/docparser/mineru_cloud_converter.go:453
if imageBytes+int64(len(imgData)) > maxImages {
return "", nil, fmt.Errorf("%w: images in %q exceed %d bytes",
errResultPackageTooLarge, logLabel, maxImages)
}
Returns empty markdown, empty imageRefs, and an error. The knowledge entry ends up parse_status=failed.
Expected result
Either of:
- The document parses (as it did on 0.8.3), or
- The cap becomes configurable, or
- Reaching the cap degrades gracefully (keep text chunks and the images that fit, log the remainder) instead of discarding the whole document.
Evidence — why this is a v0.9.0 regression, not a pre-existing limit
1. The file and constant do not exist in v0.8.3.
v0.8.3: internal/infrastructure/docparser/zip_limits.go -> does not exist
v0.9.0: internal/infrastructure/docparser/zip_limits.go:29
maxZipImagesTotalBytes = 512 << 20 // 536,870,912
2. v0.8.3 parsed the same content successfully. From our own historical parse log on 0.8.3:
[adapter] rewrite done: 540 pages @250dpi, zip 569452622 -> 586694469 bytes (images 658308530)
...
[adapter] rendered page 39 @250dpi -> 916532 bytes (4136x2924 PNG)
and for the 524-page volume the images totalled 1,107,628,027 B, which 0.8.3 ingested fully (text chunks + all page images indexed). Our internal note at the time recorded explicitly: "the assumption that WeKnora has a 512 MB unzip budget was disproven by this measurement — WeKnora unzipped all 1.03 GiB, chunked and indexed it, without a single complaint." v0.9.0 now enforces exactly that assumption.
3. Both engine paths are affected, not just the Cloud converter. extractMarkdownZip was rewritten in v0.9.0 as a thin wrapper:
// v0.9.0 internal/infrastructure/docparser/mineru_cloud_converter.go:386
func extractMarkdownZip(zipData []byte, logLabel string) (string, []types.ImageRef, error) {
return extractMarkdownZipBounded(zipData, logLabel, maxZipImagesTotalBytes)
}
The self-hosted V1 client calls the same function (mineru_v1_client.go:276), so a deployment using mineru_endpoint (self-hosted MinerU) hits the 512 MiB cap too. In v0.8.3 this same function body was the full 2011-byte implementation with no image-budget argument.
4. No configuration escape hatch. grep over internal/ shows the constant is referenced only as a literal argument; docparser reads env only for MAX_FILE_SIZE_MB (upload size) and IMAGE_HOST_KEEP_URL. There is no WEKNORA_* variable covering the decompressed-image budget.
Note the download-side cap (mineruV1MaxZipBytes = 1 << 30, i.e. 1 GiB compressed) is a different limit and does not help: our 586 MB zip passes it and then fails on decompressed images.
Impact
Any deployment that parses large technical documents at high render settings is affected. Construction / engineering drawing volumes routinely exceed 500 pages, and lossless PNG at 250 DPI puts a 500+ page volume over 512 MiB of images as a matter of course. Lowering DPI or switching to JPEG reduces text-extraction quality, which for drawings is the whole point of the pipeline.
Suggested fix
Any one of these would unblock us:
- Make the budget configurable, e.g.
WEKNORA_MINERU_MAX_IMAGE_BYTES(default 512 MiB to preserve current behaviour). - Degrade instead of fail: when the accumulated image bytes exceed the cap, keep the markdown and the images already extracted, log a warning with the counts, and mark the document parsed-with-warnings. A page-image budget overrun should not throw away the text layer, which is often the more valuable half.
- At minimum, make the failure message name the actual limit and the actual total, so operators can see why a large document failed without reading source.
Workarounds available to us today (for other reporters)
- Split the PDF upstream into volumes whose page images stay under 512 MiB (e.g. 270 pages per part at 250 DPI). No quality loss, more parse jobs.
- Reduce render DPI / switch to JPEG in the adapter so the total lands under the cap. Quality loss.
- Patch the constant and rebuild the app image. Maintenance cost on every upgrade.