{"record":{"id":"9608d776d0d714a4","repo":"docling-project/docling","slug":"archive-exceeds-maximum-member-count-limit-of-sel","errorCode":null,"errorMessage":"Archive exceeds maximum member count limit of {self.options.max_member_count}","messagePattern":"Archive exceeds maximum member count limit of (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"docling/backend/mets_gbs_backend.py","lineNumber":262,"sourceCode":"    ):\n        if options is None:\n            options = MetsGbsBackendOptions()\n        super().__init__(in_doc, path_or_stream, options)\n        self.options: MetsGbsBackendOptions\n        self._tar: tarfile.TarFile = (\n            tarfile.open(name=self.path_or_stream, mode=\"r:gz\")\n            if isinstance(self.path_or_stream, Path)\n            else tarfile.open(fileobj=self.path_or_stream, mode=\"r:gz\")\n        )\n        self.root_mets: etree._Element | None = None\n        self.page_map: dict[int, _PageFiles] = {}\n        self._total_bytes_extracted = 0\n        member_count = 0\n\n        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","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/backend/mets_gbs_backend.py#L244-L280","documentation":"ValueError raised during METS/GBS archive validation: while scanning tar members during init, the backend counts entries and aborts as soon as the count exceeds options.max_member_count. This is a deliberate decompression-bomb / resource-exhaustion guard limiting how many members a single .tar.gz may contain.","triggerScenarios":"Calling convert() on a METS GBS .tar.gz whose member count exceeds the configured max_member_count (default defined in MetsGbsBackendOptions). The check trips on member number max_member_count+1 regardless of member sizes.","commonSituations":"Large multi-volume book archives, archives with many small per-page files, or hostile/corrupted archives padded with thousands of members. Also when defaults were lowered or a user set a very small max_member_count.","solutions":["Raise the limit: pass MetsGbsBackendOptions(max_member_count=<N>) large enough for your archives.","Inspect the archive (`tar -tzf file.tar.gz | wc -l`) to confirm the true member count and detect padding/pollution.","Split oversized archives into per-volume METS packages that each fit under the limit.","Keep the guard enabled for untrusted input — it exists to prevent resource exhaustion."],"exampleFix":"# before\nresult = converter.convert(mets_path)  # ValueError: member count\n\n# after\nfrom docling.backend.mets_gbs_backend import MetsGbsBackendOptions\nopts = MetsGbsBackendOptions(max_member_count=20000)\nconverter = DocumentConverter(format_options={InputFormat.METS_GBS: PdfPipelineOptions(backend_options=opts)})\nresult = converter.convert(mets_path)","handlingStrategy":"validation","validationCode":"import tarfile\n\ndef member_count_ok(tar_path: str, limit: int) -> bool:\n    with tarfile.open(tar_path) as t:\n        return len(t.getmembers()) <= limit","typeGuard":null,"tryCatchPattern":"try:\n    result = converter.convert(mets_path)\nexcept ValueError as e:\n    if 'maximum member count' in str(e):\n        opts = MetsGbsBackendOptions(max_member_count=REASONABLE_CAP)\n        result = converter_with(opts).convert(mets_path)\n    else:\n        raise","preventionTips":["Size max_member_count from your largest legitimate archive before batch runs.","Count members (`tar -tzf f | wc -l`) during ingest validation.","Split mega-archives into per-volume packages instead of raising limits blindly."],"tags":["mets","archive","security","limits","validation"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}