[PR #12265] fix: handle non-semver cached versions in plugin installer #14140

Open
opened 2026-02-16 18:18:57 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12265

State: open
Merged: No


When a plugin is configured without a version (e.g. 'opencode-gemini-auth' instead of 'opencode-gemini-auth@1.3.8'), the version defaults to 'latest'. This caused semver.order() to throw 'Invalid SemVer: latest' because 'latest' is not a valid semver string.

Two fixes:

  1. Guard isOutdated() against non-semver cached versions by checking the format before passing to semver.order(), treating them as outdated so the package gets re-installed with a proper version
  2. Prevent 'latest' from being persisted as a cached version in the dependency map, so subsequent runs don't encounter the invalid string
  3. Validate cached versions before checking if outdated, removing corrupted cache entries

Also adds comprehensive tests to verify the fix works correctly.

Fixes #12143

What does this PR do?

Please provide a description of the issue (if there is one), the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the pr.

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

How did you verify your code works?

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12265 **State:** open **Merged:** No --- When a plugin is configured without a version (e.g. 'opencode-gemini-auth' instead of 'opencode-gemini-auth@1.3.8'), the version defaults to 'latest'. This caused semver.order() to throw 'Invalid SemVer: latest' because 'latest' is not a valid semver string. Two fixes: 1. Guard isOutdated() against non-semver cached versions by checking the format before passing to semver.order(), treating them as outdated so the package gets re-installed with a proper version 2. Prevent 'latest' from being persisted as a cached version in the dependency map, so subsequent runs don't encounter the invalid string 3. Validate cached versions before checking if outdated, removing corrupted cache entries Also adds comprehensive tests to verify the fix works correctly. Fixes #12143 ### What does this PR do? Please provide a description of the issue (if there is one), the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the pr. **If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!** ### How did you verify your code works?
yindo added the pull-request label 2026-02-16 18:18:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14140