{"record":{"id":"276ce7350635122f","repo":"huggingface/transformers","slug":"could-not-find-toc-entry-for-old-lowercase-name","errorCode":null,"errorMessage":"Could not find TOC entry for {old_lowercase_name}","messagePattern":"Could not find TOC entry for (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/cli/add_new_model_like.py","lineNumber":338,"sourceCode":"):\n    \"\"\"\n    Insert the new model in the doc `_toctree.yaml`, in the same section as the old model.\n\n    Args:\n        old_lowercase_name (`str`):\n            The old lowercase model name.\n        new_lowercase_name (`str`):\n            The new lowercase model name.\n        new_model_paper_name (`str`):\n            The fully cased name (as in the official paper name) of the new model.\n    \"\"\"\n    toc_file = repo_path / \"docs\" / \"source\" / \"en\" / \"_toctree.yml\"\n    with open(toc_file, \"r\") as f:\n        content = f.read()\n\n    toc_match = re.search(rf\"- local: model_doc/{old_lowercase_name}\\n {{8}}title: .*?\\n\", content)\n    if toc_match is None:\n        raise ValueError(f\"Could not find TOC entry for {old_lowercase_name}\")\n    old_model_toc = toc_match.group(0)\n    new_toc = f\"      - local: model_doc/{new_lowercase_name}\\n        title: {new_model_paper_name}\\n\"\n    add_content_to_file(\n        repo_path / \"docs\" / \"source\" / \"en\" / \"_toctree.yml\", new_content=new_toc, add_after=old_model_toc\n    )\n\n\ndef create_init_file(old_lowercase_name: str, new_lowercase_name: str, filenames_to_add: list[tuple[str, bool]]):\n    \"\"\"\n    Create the `__init__.py` file to add in the new model folder.\n\n    Args:\n        old_lowercase_name (`str`):\n            The old lowercase model name.\n        new_lowercase_name (`str`):\n            The new lowercase model name.\n        filenames_to_add (`list[tuple[str, bool]]`):\n            A list of tuples of all potential filenames to add for a new model, along a boolean flag describing if we","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/cli/add_new_model_like.py#L320-L356","documentation":"The add_new_model_like CLI copies the documentation TOC entry of the base model to register the new model. It searches docs/source/en/_toctree.yml for a line matching `- local: model_doc/{old_lowercase_name}` followed by a title line. If that regex does not match, it raises ValueError because the new model's docs entry cannot be inserted.","triggerScenarios":"Running add-new-model-like where the old model has no model_doc page (e.g. a model type whose docs are merged into another page); the _toctree.yml formatting changed (different indentation than 8 spaces or a reordered title line); the old name contains characters that were normalized differently than the doc entry.","commonSituations":"Using a base model whose documentation is embedded in a parent page; running the command on a repo checkout where docs were reorganized; regex breakage after a docs tooling refactor changes indentation in _toctree.yml.","solutions":["Pick a base model that has its own model_doc/<name> entry in docs/source/en/_toctree.yml","Manually add a `- local: model_doc/{old_name}` entry (with 8-space-indented `title:` line) to _toctree.yml and re-run","Add the new model's TOC entry by hand and skip the automated step"],"exampleFix":"# before: base model 'tiny_bert' has no model_doc page\n# after: add to docs/source/en/_toctree.yml\n      - local: model_doc/tiny_bert\n        title: Tiny BERT","handlingStrategy":"validation","validationCode":"import re\nfrom pathlib import Path\n\ncontent = (Path(\"docs/source/en/_toctree.yml\")).read_text()\nif not re.search(rf\"- local: model_doc/{old_name}\\n {{8}}title: .*?\\n\", content):\n    print(f\"No TOC entry for {old_name}; add it or pick another base model\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose a base model with its own model_doc page","Keep the _toctree.yml entry format intact (8-space indented title line)","Run the command from an up-to-date repo checkout so docs layout matches expectations"],"tags":["cli","docs","toctree","valueerror","developer-tooling"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}