Aider-AI/aider · error · ValueError

Could not find version header in HISTORY.md

Error message

Could not find version header in HISTORY.md

What it means

scripts/update-history.py maintains HISTORY.md from git history. get_latest_version_from_history greps HISTORY.md for the regex '### Aider v(\d+\.\d+\.\d+)' to find the most recent release header; if no header matches, it raises ValueError. Note re.search returns the FIRST match in file order, so this assumes the newest version appears first. The failure means HISTORY.md lacks any correctly-formatted '### Aider v x.y.z' heading — uncommitted initial file, mangled formatting, or wrong working directory (the file is opened by relative path).

Source

Thrown at scripts/update-history.py:19

#!/usr/bin/env python3

import os
import re
import subprocess
import sys
import tempfile

from history_prompts import history_prompt


def get_latest_version_from_history():
    with open("HISTORY.md", "r") as f:
        history_content = f.read()

    # Find most recent version header
    match = re.search(r"### Aider v(\d+\.\d+\.\d+)", history_content)
    if not match:
        raise ValueError("Could not find version header in HISTORY.md")
    return match.group(1)


def run_git_log():
    latest_ver = get_latest_version_from_history()
    cmd = [
        "git",
        "log",
        "--pretty=full",
        f"v{latest_ver}..HEAD",
        "--",
        "aider/",
        ":!aider/website/",
        ":!scripts/",
        ":!HISTORY.md",
    ]
    result = subprocess.run(cmd, capture_output=True, text=True)
    return result.stdout

View on GitHub (pinned to 5dc9490bb3)

Solutions

  1. Ensure at least one heading exactly matches '### Aider v0.0.0'-style format — three hashes, 'Aider v', dotted triple — and that the newest release is the first such heading.
  2. Run the script from the repository root (it opens 'HISTORY.md' relatively).
  3. Restore/undo any heading-style edits to HISTORY.md (git checkout HISTORY.md).

Example fix

# before
## Aider 1.2.3  # wrong level, missing 'v'

# after
### Aider v1.2.3
Defensive patterns

Strategy: validation

Validate before calling

import re

def history_has_version_header(path="HISTORY.md") -> bool:
    text = open(path).read()
    return re.search(r"### Aider v\d+\.\d+\.\d+", text) is not None

Prevention

When it happens

Trigger: Running scripts/update-history.py from a directory without HISTORY.md (FileNotFoundError would hit first only if the file is absent; a present-but-unformatted file reaches this raise), or with headers edited to '### Aider 1.2.3' (missing 'v'), '## Aider v1.2.3' (wrong level), or extra text breaking the exact '### Aider vX.Y.Z' pattern.

Common situations: Maintainer/fork workflows: reformatting HISTORY.md, converting to another heading style, running the script from a subdirectory, or a fresh clone of a fork whose HISTORY.md was trimmed.

Related errors


AI-assisted analysis of Aider-AI/aider@5dc9490bb3 (2026-08-15). Data as JSON: /api/errors/0ab6bd2ded8f0008. Report an issue: GitHub.