[Bug] Invalid semver parsing in changelog version extraction

Resolved 💬 2 comments Opened Jan 7, 2026 by msenol Closed Jan 15, 2026

Bug Description

---

Bug Report: Invalid Version Parse Error in Claude Code CLI v2.1.0

Summary

Claude Code CLI crashes with "Invalid Version" error when parsing the cached changelog.md file due to improper semver parsing of version strings that include release dates.

Environment

  • Claude Code Version: 2.1.0
  • Node.js Version: v24.12.0
  • OS: Linux (Pop!_OS / Ubuntu-based) - kernel 6.17.9-76061709-generic
  • Installation Method: Global npm install (/home/user/.nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/claude-code/)

Error Message

ERROR  Invalid Version: 2.1.0 (2026-01-07)

 file:///home/user/.nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:869:8900

 - iT (file:///.../@anthropic-ai/claude-code/cli.js:869:8900)
 - SJ8 (file:///.../@anthropic-ai/claude-code/cli.js:869:14028)
 - Object.dJ8 (file:///.../@anthropic-ai/claude-code/cli.js:869:14584)
 -  (file:///.../@anthropic-ai/claude-code/cli.js:3091:4240)
 -     at Array.sort (<anonymous>)
 - de2 (file:///.../@anthropic-ai/claude-code/cli.js:3091:4224)
 - VA9 (file:///.../@anthropic-ai/claude-code/cli.js:3091:13453)
 - GY (file:///.../@anthropic-ai/claude-code/cli.js:743:20692)
 - V8 (file:///.../@anthropic-ai/claude-code/cli.js:743:39055)
 - Ae (file:///.../@anthropic-ai/claude-code/cli.js:743:49661)

Root Cause Analysis

The error originates from the cached changelog file at ~/.claude/cache/changelog.md. The file contains version headers in the format:

## 2.1.0 (2026-01-07)

When Claude Code CLI parses this file (likely during startup or version comparison), it extracts the version string as 2.1.0 (2026-01-07) instead of just 2.1.0. This malformed string is then passed to a semver parsing function which throws the "Invalid Version" error because:

  • Valid semver format: MAJOR.MINOR.PATCH (e.g., 2.1.0)
  • Extracted string: 2.1.0 (2026-01-07) (includes date in parentheses)

The stack trace shows the error occurs during an Array.sort() operation in the de2 function, suggesting versions are being sorted/compared, which requires valid semver parsing.

Steps to Reproduce

  1. Install Claude Code CLI globally via npm
  2. Run claude in any project directory
  3. Wait for the changelog to be fetched and cached at ~/.claude/cache/changelog.md
  4. The error occurs on subsequent launches when the CLI attempts to parse the cached changelog

Workaround

Delete the cached changelog file:

rm ~/.claude/cache/changelog.md

Or clear the entire cache:

rm -rf ~/.claude/cache/

Note: This is a temporary fix. The bug may reoccur when the changelog is re-fetched.

Suggested Fix

The regex or parsing logic that extracts version numbers from changelog headers should be updated to capture only the semver portion. For example:

// Current (problematic) - likely capturing everything after "## "
const version = line.match(/^## (.+)$/)?.[1];

// Suggested fix - capture only the semver portion
const version = line.match(/^## (\d+\.\d+\.\d+)/)?.[1];
// Or with optional prerelease/metadata support:
const version = line.match(/^## (\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?(?:\+[a-zA-Z0-9.]+)?)/)?.[1];

Additional Context

  • The error prevents Claude Code from starting in any project
  • The changelog format ## X.Y.Z (YYYY-MM-DD) is a common convention and should be handled gracefully
  • The date in the changelog header (2026-01-07) appears to be a future date, which might indicate a test/pre-release version or incorrect date

---

Environment Info

  • Platform: linux
  • Terminal: cursor
  • Version: 2.1.0
  • Feedback ID: 851b0f73-8be9-4e61-a218-c1d0157478ad

Errors

[{"error":"AggregateError\n    at r5A.from (file:///home/msenol/.nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:43:59581)\n    at yU.<anonymous> (file:///home/msenol/.nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:57:10021)\n    at yU.emit (node:events:520:35)\n    at yU.emit (node:domain:489:12)\n    at wL1.<computed> (file:///home/msenol/.nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:56:3436)\n    at ClientRequest.emit (node:events:520:35)\n    at ClientRequest.emit (node:domain:489:12)\n    at emitErrorEvent (node:_http_client:108:11)\n    at TLSSocket.socketErrorListener (node:_http_client:575:5)\n    at TLSSocket.emit (node:events:508:28)\n    at e$A.request (file:///home/msenol/.nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:59:2132)\n    at processTicksAndRejections (node:internal/process/task_queues:103:5)\n    at runNextTicks (node:internal/process/task_queues:68:3)\n    at listOnTimeout (node:internal/timers:567:9)\n    at process.processTimers (node:internal/timers:541:7)\n    at async L$3 (file:

Note: Error logs were truncated.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗