{"record":{"id":"dd5fde465e78c66d","repo":"docling-project/docling","slug":"archive-exceeds-maximum-total-extraction-size-of","errorCode":null,"errorMessage":"Archive exceeds maximum total extraction size of {self.options.max_total_bytes} bytes","messagePattern":"Archive exceeds maximum total extraction size of (.+?) bytes","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"docling/backend/mets_gbs_backend.py","lineNumber":277,"sourceCode":"        for member in self._tar.getmembers():\n            member_count += 1\n            if member_count > self.options.max_member_count:\n                raise ValueError(\n                    f\"Archive exceeds maximum member count limit of {self.options.max_member_count}\"\n                )\n\n            if member.name.endswith(\".xml\"):\n                file = self._tar.extractfile(member)\n                if file is not None:\n                    content = file.read(self.options.max_file_bytes + 1)\n                    if len(content) > self.options.max_file_bytes:\n                        raise ValueError(\n                            f\"XML file {member.name} exceeds size limit of {self.options.max_file_bytes} bytes\"\n                        )\n\n                    self._total_bytes_extracted += len(content)\n                    if self._total_bytes_extracted > self.options.max_total_bytes:\n                        raise ValueError(\n                            f\"Archive exceeds maximum total extraction size of {self.options.max_total_bytes} bytes\"\n                        )\n\n                    self.root_mets = self._validate_mets_xml(content)\n                    if self.root_mets is not None:\n                        break\n\n        if self.root_mets is None:\n            raise DocumentLoadError(\n                f\"METS GBS backend could not load document {self.document_hash}.\"\n            )\n\n        ns = {\n            \"mets\": \"http://www.loc.gov/METS/\",\n            \"xlink\": \"http://www.w3.org/1999/xlink\",\n            \"xsi\": \"http://www.w3.org/2001/XMLSchema-instance\",\n            \"gbs\": \"http://books.google.com/gbs\",\n            \"premis\": \"info:lc/xmlns/premis-v2\",","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/backend/mets_gbs_backend.py#L259-L295","documentation":"ValueError raised during METS/GBS init when the running sum of bytes extracted from XML members exceeds options.max_total_bytes. Each XML member read is added to self._total_bytes_extracted and the cumulative total is capped, preventing aggregate decompression-bomb expansion across many members.","triggerScenarios":"Converting an archive whose combined XML member sizes exceed max_total_bytes — either many medium-sized XML files or several large ones. Trips during the member scan in __init__, before the METS root is even identified.","commonSituations":"Multi-book bundles, archives that include both METS and bulky ALTO/page OCR XML, or a lowered default max_total_bytes. Also malicious archives with many expanding members.","solutions":["Raise MetsGbsBackendOptions(max_total_bytes=...) to comfortably exceed the archive's total uncompressed XML size.","Measure the real total: `tar -xzOf file.tar.gz '*.xml' | wc -c` (bounded) or inspect member sizes with `tar -tvzf`.","Split the archive so each package stays under the budget.","Treat an unexpectedly huge total on untrusted input as a red flag rather than a configuration problem."],"exampleFix":"# before\nresult = converter.convert(mets_path)  # ValueError: total extraction size\n\n# after\nopts = MetsGbsBackendOptions(max_total_bytes=4 * 1024 * 1024 * 1024)\n# pass opts via format options, then convert\nresult = converter.convert(mets_path)","handlingStrategy":"validation","validationCode":"import tarfile\n\ndef xml_total_within(tar_path: str, cap: int) -> bool:\n    with tarfile.open(tar_path) as t:\n        return sum(m.size for m in t.getmembers() if m.name.endswith('.xml')) <= cap","typeGuard":null,"tryCatchPattern":"try:\n    result = converter.convert(mets_path)\nexcept ValueError as e:\n    if 'maximum total extraction size' in str(e):\n        opts = MetsGbsBackendOptions(max_total_bytes=BUDGET)\n        result = converter_with(opts).convert(mets_path)\n    else:\n        raise","preventionTips":["Budget max_total_bytes against total uncompressed XML size, not file count.","Measure totals during ingest with tar member-size sums.","Split bundles whose metadata alone exceeds budget."],"tags":["mets","archive","security","limits","decompression-bomb"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}