{"record":{"id":"4ec4d474646e2d64","repo":"tiangolo/fastapi","slug":"couldn-t-find-pre-section-style-in-index-md","errorCode":null,"errorMessage":"Couldn't find pre section (<style>) in index.md","messagePattern":"Couldn't find pre section \\(<style>\\) in index\\.md","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"scripts/docs.py","lineNumber":359,"sourceCode":"            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\n\n","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/tiangolo/fastapi/blob/3e8d1526d83a90aaf7d6eb6dc682bf150f180b25/scripts/docs.py#L341-L377","documentation":"Raised by generate_readme_content() in scripts/docs.py:359. After slicing the sponsor section it also needs the end of the front-matter <style> block to know where the README body begins: it searches index.md for '</style>\\n\\n' (scripts/docs.py:351). If that exact sequence is absent the README preamble cannot be reconstructed and the function aborts.","triggerScenarios":"Running generate-readme (or generate_readme_content) after the '<style>' block in docs/en/docs/index.md was removed, moved, or reformatted so the literal '</style>\\n\\n' no longer appears.","commonSituations":"The <style> tag was reformatted (e.g. minified onto one line, or trailing blank line removed). The style block was deleted entirely. A formatter collapsed the blank line after </style>.","solutions":["Open docs/en/docs/index.md and verify a '<style>...</style>' block exists ending with '</style>' followed by a blank line.","Restore the exact '</style>\\n\\n' sequence from git history.","Re-run generate-readme."],"exampleFix":"<!-- before: blank line after </style> removed -->\n</style>\n## FastAPI\n<!-- after: restore the blank line -->\n</style>\n\n## FastAPI","handlingStrategy":"validation","validationCode":"from pathlib import Path\nimport re\n\ndef has_style_block(index_md: Path) -> bool:\n    return re.search(r\"</style>\\n\\n\", index_md.read_text(encoding=\"utf-8\")) is not None","typeGuard":null,"tryCatchPattern":"try:\n    content = generate_readme_content()\nexcept RuntimeError as e:\n    if \"pre section\" in str(e):\n        raise RuntimeError(\"index.md missing '</style>\\n\\n'; restore the style block\") from e\n    raise","preventionTips":["Keep a '<style>...</style>' block ending with '</style>' followed by a blank line at the top of index.md.","Avoid formatters that collapse trailing blank lines.","CI: assert '</style>\\n\\n' is present in index.md."],"tags":["docs","sponsors","markdown","validation"],"backgroundTag":null,"analyzedSha":"3e8d1526d83a90aaf7d6eb6dc682bf150f180b25","analyzedAt":"2026-08-11T02:34:52.986Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}