{"record":{"id":"a8cfcccbfe22a12e","repo":"tiangolo/fastapi","slug":"couldn-t-auto-generate-sponsors-section","errorCode":null,"errorMessage":"Couldn't auto-generate sponsors section","messagePattern":"Couldn't auto-generate sponsors section","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"scripts/docs.py","lineNumber":357,"sourceCode":"        match = header_with_permalink_pattern.match(line)\n        if match:\n            hashes, title, *_ = match.groups()\n            line = f\"{hashes} {title}\"\n        lines.append(line)\n    return \"\\n\".join(lines)\n\n\ndef generate_readme_content() -> str:\n    en_index = en_docs_path / \"docs\" / \"index.md\"\n    content = en_index.read_text(\"utf-8\")\n    content = remove_header_permalinks(content)  # remove permalinks from headers\n    match_pre = re.search(r\"</style>\\n\\n\", content)\n    match_start = re.search(r\"<!-- sponsors -->\", content)\n    match_end = re.search(r\"<!-- /sponsors -->\", content)\n    sponsors_data_path = en_docs_path / \"data\" / \"sponsors.yml\"\n    sponsors = yaml.safe_load(sponsors_data_path.read_text(encoding=\"utf-8\"))\n    if not (match_start and match_end):\n        raise RuntimeError(\"Couldn't auto-generate sponsors section\")\n    if not match_pre:\n        raise RuntimeError(\"Couldn't find pre section (<style>) in index.md\")\n    frontmatter_end = match_pre.end()\n    pre_end = match_start.end()\n    post_start = match_end.start()\n    template = Template(index_sponsors_template)\n    message = template.render(sponsors=sponsors, sponsor_img_url=sponsor_img_url)\n    pre_content = content[frontmatter_end:pre_end]\n    post_content = content[post_start:]\n    new_content = pre_content + message + post_content\n    # Remove content between <!-- only-mkdocs --> and <!-- /only-mkdocs -->\n    new_content = re.sub(\n        r\"<!-- only-mkdocs -->.*?<!-- /only-mkdocs -->\",\n        \"\",\n        new_content,\n        flags=re.DOTALL,\n    )\n    return new_content","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/tiangolo/fastapi/blob/3e8d1526d83a90aaf7d6eb6dc682bf150f180b25/scripts/docs.py#L339-L375","documentation":"Raised by generate_readme_content() in scripts/docs.py:357 when it cannot locate the sponsor placeholder markers in docs/en/docs/index.md. The README is generated by slicing index.md between the markers '<!-- sponsors -->' and '<!-- /sponsors -->' (scripts/docs.py:352-353) and injecting rendered sponsor HTML. If either marker is absent the slice boundaries are undefined, so the function aborts rather than emit a malformed README.","triggerScenarios":"Running `python scripts/docs.py generate-readme` (or any workflow calling generate_readme_content) after the sponsor markers were removed or renamed in docs/en/docs/index.md. Fires when match_start or match_end is falsy at scripts/docs.py:356.","commonSituations":"Someone edited index.md and deleted/renamed the sponsor HTML comment markers. A find-and-replace rewrote HTML comments. The index.md file was regenerated from a template that omits the markers.","solutions":["Open docs/en/docs/index.md and confirm both '<!-- sponsors -->' and '<!-- /sponsors -->' are present exactly as written.","Restore the markers from git history: git log -p -- docs/en/docs/index.md | grep -n 'sponsors'.","Re-run generate-readme once both markers exist."],"exampleFix":"<!-- before: markers missing -->\n## FastAPI\n...\n<!-- after: restore both markers -->\n## FastAPI\n<!-- sponsors -->\n<!-- /sponsors -->","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef has_sponsor_markers(index_md: Path) -> bool:\n    text = index_md.read_text(encoding=\"utf-8\")\n    return \"<!-- sponsors -->\" in text and \"<!-- /sponsors -->\" in text","typeGuard":null,"tryCatchPattern":"try:\n    content = generate_readme_content()\nexcept RuntimeError as e:\n    if \"sponsors\" in str(e):\n        raise RuntimeError(\"index.md is missing sponsor markers; restore them\") from e\n    raise","preventionTips":["Treat the sponsor HTML comment markers as load-bearing; never delete them in index.md.","Add a CI grep assertion for both markers before generate-readme.","Code-review edits to index.md front matter and sponsor block."],"tags":["docs","sponsors","markdown","validation"],"backgroundTag":null,"analyzedSha":"3e8d1526d83a90aaf7d6eb6dc682bf150f180b25","analyzedAt":"2026-08-11T02:34:52.986Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}