Skip to content

Bug: inserting a section into the changelog — incorrect index check #4400

@Peopl3s

Description

@Peopl3s

Description

def _write_changelog_entry(changelog_entry: str) -> None:

def _write_changelog_entry(changelog_entry: str) -> None:
    changelog_path = pathlib.Path("docs/release-notes/changelog.rst")
    changelog_lines = changelog_path.read_text().splitlines()
    line_no = next(
        (i for i, line in enumerate(changelog_lines) if line.startswith(".. changelog::")),
        None,
    )
    if not line_no:
        raise ValueError("Changelog start not found")

    changelog_lines[line_no:line_no] = changelog_entry.splitlines()
    changelog_path.write_text("\n".join(changelog_lines))

if the marker is on the first line (index 0), the if not line_no condition will fail.

What to do: replace it with if line_no is None:.

URL to code causing the issue

No response

MCVE

Steps to reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots

No response

Logs


Litestar Version

2.17.0

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛This is something that is not working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions