Aider-AI/aider · error · ValueError

Could not find version header: {version_header}

Error message

Could not find version header: {version_header}

What it means

Companion check in scripts/update-history.py: having found '# Release history', it then searches for the specific header f'### Aider v{latest_ver}' after the anchor. Since latest_ver was itself extracted from the same file moments earlier, this raise normally signals an inconsistency: the first regex match came from BEFORE the anchor (e.g. stale version headers in an intro section above '# Release history'), so the same version has no header inside the release-history section itself.

Source

Thrown at scripts/update-history.py:77

    # Get the git log and diff output
    log_content = run_git_log()
    diff_content = run_git_diff()

    # Extract relevant portion of HISTORY.md
    latest_ver = get_latest_version_from_history()
    with open("HISTORY.md", "r") as f:
        history_content = f.read()

    # Find the section for this version
    version_header = f"### Aider v{latest_ver}"
    start_idx = history_content.find("# Release history")
    if start_idx == -1:
        raise ValueError("Could not find start of release history")

    # Find where this version's section ends
    version_idx = history_content.find(version_header, start_idx)
    if version_idx == -1:
        raise ValueError(f"Could not find version header: {version_header}")

    # Find the next version header after this one
    next_version_idx = history_content.find("\n### Aider v", version_idx + len(version_header))
    if next_version_idx == -1:
        # No next version found, use the rest of the file
        relevant_history = history_content[start_idx:]
    else:
        # Extract just up to the next version
        relevant_history = history_content[start_idx:next_version_idx]

    # Save relevant portions to temporary files
    with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".log") as tmp_log:
        tmp_log.write(log_content)
        log_path = tmp_log.name

    with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".diff") as tmp_diff:
        tmp_diff.write(diff_content)
        diff_path = tmp_diff.name

View on GitHub (pinned to 5dc9490bb3)

Solutions

  1. Ensure the only '### Aider v...' headings live after the '# Release history' anchor, newest first.
  2. Remove duplicate/stale version headers above the anchor so the first regex match is a real release entry.
  3. Re-add the heading '### Aider v{latest_ver}' inside the release section if it was accidentally removed.

Example fix

# before
### Aider v1.5.0   # preamble copy confuses version lookup
Some intro text...
# Release history
### Aider v1.4.2

# after
Some intro text (no version headings here)...
# Release history
### Aider v1.5.0   # newest, first after anchor
### Aider v1.4.2
Defensive patterns

Strategy: validation

Validate before calling

def history_is_consistent(path="HISTORY.md") -> bool:
    text = open(path).read()
    anchor = text.find("# Release history")
    m = re.search(r"### Aider v(\d+\.\d+\.\d+)", text)
    return anchor != -1 and m is not None and text.find(f"### Aider v{m.group(1)}", anchor) != -1

Prevention

When it happens

Trigger: A '### Aider vX.Y.Z' heading existing above the '# Release history' anchor (intro/summary section) so get_latest_version_from_history picks it up, while the actual release section starts at a different/older version; or the file being modified between the two reads (rare — both open HISTORY.md fresh).

Common situations: Changelogs with a 'recent highlights' preamble that repeats version headings before the formal release-history section; partial reorganizations where the newest entry was moved above the anchor.

Related errors


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