{"record":{"id":"ed22c9ff985f8162","repo":"docling-project/docling","slug":"could-not-initialize-asciidoc-backend-for-file-wit","errorCode":null,"errorMessage":"Could not initialize AsciiDoc backend for file with hash {self.document_hash}.","messagePattern":"Could not initialize AsciiDoc backend for file with hash (.+?)\\.","errorType":"exception","errorClass":"DocumentLoadError","httpStatus":null,"severity":"error","filePath":"docling/backend/asciidoc_backend.py","lineNumber":50,"sourceCode":"\n\nclass AsciiDocBackend(DeclarativeDocumentBackend):\n    def __init__(self, in_doc: \"InputDocument\", path_or_stream: Union[BytesIO, Path]):\n        super().__init__(in_doc, path_or_stream)\n\n        self.path_or_stream = path_or_stream\n\n        try:\n            if isinstance(self.path_or_stream, BytesIO):\n                text_stream = self.path_or_stream.getvalue().decode(\"utf-8\")\n                self.lines = text_stream.split(\"\\n\")\n            if isinstance(self.path_or_stream, Path):\n                with open(self.path_or_stream, encoding=\"utf-8\") as f:\n                    self.lines = f.readlines()\n            self.valid = True\n\n        except Exception as e:\n            raise DocumentLoadError(\n                f\"Could not initialize AsciiDoc backend for file with hash {self.document_hash}.\"\n            ) from e\n        return\n\n    def is_valid(self) -> bool:\n        return self.valid\n\n    @classmethod\n    def supports_pagination(cls) -> bool:\n        return False\n\n    def unload(self):\n        return\n\n    @classmethod\n    def supported_formats(cls) -> set[InputFormat]:\n        return {InputFormat.ASCIIDOC}\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/backend/asciidoc_backend.py#L32-L68","documentation":"Raised by the benchmark script's _runtime_info() helper when its regex `^version\\s*=\\s*\"([^\"]+)\"` (MULTILINE) finds no match in the pyproject.toml located at Path(__file__).resolve().parents[1]. The script records the Docling version in every benchmark result line, so it refuses to run without it. This is a script-environment sanity check, not a Docling library error: it fires when the pyproject.toml next to perfs/ is missing, not a project file, or declares its version in a format the regex does not recognize.","triggerScenarios":"Running perfs/xlsx_merged_cells.py from anything other than a full Docling repository checkout (parents[1] of the script must be the repo root containing pyproject.toml); copying the script into another project whose pyproject.toml uses `dynamic = [\"version\"]` (PEP 621 dynamic version), a [tool.poetry] `version = \"...\"` line under a section with different indentation, single-quoted TOML strings, or version defined only in a submodule/package __init__.py. In this repo the top-level `version = \"2.120.1\"` matches, so the error only appears in modified/derived environments.","commonSituations":"Running the benchmark from an installed wheel/site-packages copy of the script; vendoring the script into a private benchmark repo that uses setuptools dynamic versioning or hatch version hooks; a pyproject.toml that was reformatted with single quotes or puts version inside [project] with unusual spacing/line continuations; running against a source tree where pyproject.toml was replaced by setup.py-only metadata.","solutions":["Run the script from the Docling repository root as documented: `uv run python perfs/xlsx_merged_cells.py --merge-count 100` so parents[1] resolves to the real repo with its pyproject.toml.","If you must run it elsewhere, ensure the directory containing perfs/ has a pyproject.toml with a top-level (or [project]-section) `version = \"x.y.z\"` line using double quotes.","If your pyproject uses dynamic versioning, pin the version explicitly (remove `dynamic = [\"version\"]` and add `version = \"...\"`) or adjust the regex in _runtime_info() to also match your version source (e.g. `^version = '([^']+)'` or [tool.hatch.version] paths).","Alternatively replace the pyproject parsing with `importlib.metadata.version(\"docling\")` so the version comes from the installed package instead of the source tree."],"exampleFix":"// before (perfs/xlsx_merged_cells.py:86-93)\npyproject_text = (repository_root / \"pyproject.toml\").read_text(encoding=\"utf-8\")\nversion_match = re.search(r'^version\\s*=\\s*\"([^\"]+)\"', pyproject_text, flags=re.MULTILINE)\nif version_match is None:\n    raise RuntimeError(\"Could not determine Docling version from pyproject.toml\")\n\n// after\nfrom importlib.metadata import PackageNotFoundError, version as pkg_version\ntry:\n    docling_version = pkg_version(\"docling\")\nexcept PackageNotFoundError:\n    docling_version = \"unknown\"","handlingStrategy":"validation","validationCode":"from pathlib import Path\nimport re\n\nrepository_root = Path(\"perfs/xlsx_merged_cells.py\").resolve().parents[1]\npyproject = repository_root / \"pyproject.toml\"\nif not pyproject.is_file():\n    raise SystemExit(f\"no pyproject.toml at {repository_root}; run from the Docling repo root\")\ntext = pyproject.read_text(encoding=\"utf-8\")\nif re.search(r'^version\\s*=\\s*\"([^\"]+)\"', text, flags=re.MULTILINE) is None:\n    raise SystemExit(\"pyproject.toml has no double-quoted top-level version; script cannot record docling_version\")","typeGuard":null,"tryCatchPattern":"try:\n    runtime_info = _runtime_info()\nexcept (RuntimeError, FileNotFoundError, subprocess.CalledProcessError) as exc:\n    raise SystemExit(f\"cannot collect runtime info for benchmark: {exc}\") from exc","preventionTips":["Always run perfs/ scripts from the Docling repository root via `uv run python perfs/xlsx_merged_cells.py ...` so parents[1] is the real checkout.","Keep a double-quoted `version = \"x.y.z\"` line at the top level or in [project] of pyproject.toml if you fork the benchmark.","Prefer importlib.metadata.version(\"docling\") over pyproject parsing when the script may run outside the source tree."],"tags":["benchmark","packaging","pyproject-toml","version-detection","environment"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}