{"record":{"id":"fa3967171a346a9d","repo":"Aider-AI/aider","slug":"could-not-find-version-header-version-header","errorCode":null,"errorMessage":"Could not find version header: {version_header}","messagePattern":"Could not find version header: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/update-history.py","lineNumber":77,"sourceCode":"    # Get the git log and diff output\n    log_content = run_git_log()\n    diff_content = run_git_diff()\n\n    # Extract relevant portion of HISTORY.md\n    latest_ver = get_latest_version_from_history()\n    with open(\"HISTORY.md\", \"r\") as f:\n        history_content = f.read()\n\n    # Find the section for this version\n    version_header = f\"### Aider v{latest_ver}\"\n    start_idx = history_content.find(\"# Release history\")\n    if start_idx == -1:\n        raise ValueError(\"Could not find start of release history\")\n\n    # Find where this version's section ends\n    version_idx = history_content.find(version_header, start_idx)\n    if version_idx == -1:\n        raise ValueError(f\"Could not find version header: {version_header}\")\n\n    # Find the next version header after this one\n    next_version_idx = history_content.find(\"\\n### Aider v\", version_idx + len(version_header))\n    if next_version_idx == -1:\n        # No next version found, use the rest of the file\n        relevant_history = history_content[start_idx:]\n    else:\n        # Extract just up to the next version\n        relevant_history = history_content[start_idx:next_version_idx]\n\n    # Save relevant portions to temporary files\n    with tempfile.NamedTemporaryFile(mode=\"w\", delete=False, suffix=\".log\") as tmp_log:\n        tmp_log.write(log_content)\n        log_path = tmp_log.name\n\n    with tempfile.NamedTemporaryFile(mode=\"w\", delete=False, suffix=\".diff\") as tmp_diff:\n        tmp_diff.write(diff_content)\n        diff_path = tmp_diff.name","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/Aider-AI/aider/blob/5dc9490bb35f9729ef2c95d00a19ccd30c26339c/scripts/update-history.py#L59-L95","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Ensure the only '### Aider v...' headings live after the '# Release history' anchor, newest first.","Remove duplicate/stale version headers above the anchor so the first regex match is a real release entry.","Re-add the heading '### Aider v{latest_ver}' inside the release section if it was accidentally removed."],"exampleFix":"# before\n### Aider v1.5.0   # preamble copy confuses version lookup\nSome intro text...\n# Release history\n### Aider v1.4.2\n\n# after\nSome intro text (no version headings here)...\n# Release history\n### Aider v1.5.0   # newest, first after anchor\n### Aider v1.4.2","handlingStrategy":"validation","validationCode":"def history_is_consistent(path=\"HISTORY.md\") -> bool:\n    text = open(path).read()\n    anchor = text.find(\"# Release history\")\n    m = re.search(r\"### Aider v(\\d+\\.\\d+\\.\\d+)\", text)\n    return anchor != -1 and m is not None and text.find(f\"### Aider v{m.group(1)}\", anchor) != -1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep all version headings strictly after the '# Release history' anchor — none in preambles.","Newest release first: the first regex match must be a real, in-section entry.","Automate the check (script or CI) rather than eyeballing the changelog before each release."],"tags":["release-tooling","markdown","changelog","consistency","scripts"],"backgroundTag":null,"analyzedSha":"5dc9490bb35f9729ef2c95d00a19ccd30c26339c","analyzedAt":"2026-08-15T05:40:10.498Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}