{"record":{"id":"259e31a4e35129c3","repo":"tiangolo/fastapi","slug":"could-not-find-release-notes-section-for-version","errorCode":null,"errorMessage":"Could not find release notes section for {version} in {release_notes_file}","messagePattern":"Could not find release notes section for (.+?) in (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"scripts/prepare_release.py","lineNumber":88,"sourceCode":"        raise RuntimeError(f\"Release notes already contain a section for {version}\")\n\n    latest_header = f\"{RELEASE_NOTES_HEADER}{LATEST_CHANGES_HEADER}\\n\"\n    if not content.startswith(latest_header):\n        raise RuntimeError(f\"{release_notes_file} must start with {latest_header!r}\")\n\n    release_header = f\"## {version} ({release_date.isoformat()})\"\n    return content.replace(\n        latest_header,\n        f\"{RELEASE_NOTES_HEADER}{LATEST_CHANGES_HEADER}\\n\\n{release_header}\\n\",\n        1,\n    )\n\n\ndef get_release_notes_body(content: str, version: str, release_notes_file: Path) -> str:\n    version_heading = re.compile(rf\"(?m)^## {re.escape(version)}(?: \\([^)]+\\))?$\")\n    match = version_heading.search(content)\n    if not match:\n        raise RuntimeError(\n            f\"Could not find release notes section for {version} in {release_notes_file}\"\n        )\n\n    next_match = VERSION_HEADING_PATTERN.search(content, match.end())\n    end = next_match.start() if next_match else len(content)\n    body = content[match.end() : end].strip()\n    if not body:\n        raise RuntimeError(\n            f\"Release notes section for {version} in {release_notes_file} is empty\"\n        )\n    return f\"{body}\\n\"\n\n\n@app.command()\ndef prepare(\n    bump: Annotated[\n        BumpType,\n        typer.Argument(","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/tiangolo/fastapi/blob/3e8d1526d83a90aaf7d6eb6dc682bf150f180b25/scripts/prepare_release.py#L70-L106","documentation":"Raised by get_release_notes_body() in scripts/prepare_release.py:88 when searching for the '## X.Y.Z' heading for the requested version yields no match (version_heading.search returns None at scripts/prepare_release.py:86). This command is meant to print the body of an existing release section; if the section was never created it cannot proceed.","triggerScenarios":"Running `python scripts/prepare_release.py release-notes` (which calls get_release_notes_body with the current __version__) when no matching '## <current_version>' heading exists in the release notes file. Happens right after bumping __version__ but before adding the section via prepare.","commonSituations":"The version file was bumped manually without running prepare, then release-notes is called. The heading uses a different format than VERSION_HEADING_PATTERN expects. The release notes file points at the wrong path.","solutions":["Run `prepare <bump>` first so the section for the new version is created.","Manually add a '## <version> (YYYY-MM-DD)' heading to the release notes file if you bumped the version another way.","Confirm the heading matches the pattern '## X.Y.Z' or '## X.Y.Z (date)'."],"exampleFix":"<!-- before: version 1.2.3 in file but no section -->\n## Latest Changes\n\n<!-- after -->\n## Latest Changes\n\n## 1.2.3 (2026-01-01)\n- Initial release","handlingStrategy":"validation","validationCode":"import re\nfrom pathlib import Path\n\ndef section_present(path: Path, version: str) -> bool:\n    pat = re.compile(rf\"(?m)^## {re.escape(version)}(?: \\([^)]+\\))?$\")\n    return pat.search(path.read_text(encoding=\"utf-8\")) is not None","typeGuard":null,"tryCatchPattern":"try:\n    body = get_release_notes_body(content, version, release_notes_file)\nexcept RuntimeError as e:\n    if \"Could not find release notes section\" in str(e):\n        raise SystemExit(f\"Run prepare first to create the {version} section\") from e\n    raise","preventionTips":["Run prepare before release-notes so the section exists.","Keep version headings in the '## X.Y.Z (date)' format.","Validate the release-notes file path is correct."],"tags":["release","docs","validation"],"backgroundTag":null,"analyzedSha":"3e8d1526d83a90aaf7d6eb6dc682bf150f180b25","analyzedAt":"2026-08-11T02:34:52.986Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}