{"record":{"id":"0ab6bd2ded8f0008","repo":"Aider-AI/aider","slug":"could-not-find-version-header-in-history-md","errorCode":null,"errorMessage":"Could not find version header in HISTORY.md","messagePattern":"Could not find version header in HISTORY\\.md","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/update-history.py","lineNumber":19,"sourceCode":"#!/usr/bin/env python3\n\nimport os\nimport re\nimport subprocess\nimport sys\nimport tempfile\n\nfrom history_prompts import history_prompt\n\n\ndef get_latest_version_from_history():\n    with open(\"HISTORY.md\", \"r\") as f:\n        history_content = f.read()\n\n    # Find most recent version header\n    match = re.search(r\"### Aider v(\\d+\\.\\d+\\.\\d+)\", history_content)\n    if not match:\n        raise ValueError(\"Could not find version header in HISTORY.md\")\n    return match.group(1)\n\n\ndef run_git_log():\n    latest_ver = get_latest_version_from_history()\n    cmd = [\n        \"git\",\n        \"log\",\n        \"--pretty=full\",\n        f\"v{latest_ver}..HEAD\",\n        \"--\",\n        \"aider/\",\n        \":!aider/website/\",\n        \":!scripts/\",\n        \":!HISTORY.md\",\n    ]\n    result = subprocess.run(cmd, capture_output=True, text=True)\n    return result.stdout","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/Aider-AI/aider/blob/5dc9490bb35f9729ef2c95d00a19ccd30c26339c/scripts/update-history.py#L1-L37","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Run the script from the repository root (it opens 'HISTORY.md' relatively).","Restore/undo any heading-style edits to HISTORY.md (git checkout HISTORY.md)."],"exampleFix":"# before\n## Aider 1.2.3  # wrong level, missing 'v'\n\n# after\n### Aider v1.2.3","handlingStrategy":"validation","validationCode":"import re\n\ndef history_has_version_header(path=\"HISTORY.md\") -> bool:\n    text = open(path).read()\n    return re.search(r\"### Aider v\\d+\\.\\d+\\.\\d+\", text) is not None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the newest release as the first '### Aider vX.Y.Z' heading, exact format (three #, 'v', dotted triple).","Run release scripts from the repo root — HISTORY.md is opened by relative path.","Don't restyle changelog headings without updating the regex expectations."],"tags":["release-tooling","markdown","changelog","regex","scripts"],"backgroundTag":null,"analyzedSha":"5dc9490bb35f9729ef2c95d00a19ccd30c26339c","analyzedAt":"2026-08-15T05:40:10.498Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}