fix: IsCompatible returns false for invalid semver inputs#34312
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix IsCompatible to handle invalid semver strings correctly
fix: IsCompatible returns false for invalid semver inputs
May 23, 2026
pelikhan
approved these changes
May 23, 2026
Contributor
|
|
Contributor
|
❌ Design Decision Gate 🏗️ failed during design decision gate check. |
Contributor
|
🧠 Matt Pocock Skills Reviewer failed during the skills-based review. |
Contributor
|
❌ Test Quality Sentinel failed during test quality analysis. |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a correctness bug in pkg/semverutil where IsCompatible could return true for two invalid semver strings due to semver.Major returning "" for unparseable inputs.
Changes:
- Add a validity guard in
IsCompatibleto returnfalsewhen either version is not valid semver. - Add test coverage for invalid/empty version inputs in both unit tests and spec tests.
Show a summary per file
| File | Description |
|---|---|
| pkg/semverutil/semverutil.go | Adds semver.IsValid guard to prevent invalid inputs from being treated as compatible. |
| pkg/semverutil/semverutil_test.go | Adds unit tests covering invalid/empty semver inputs for IsCompatible. |
| pkg/semverutil/spec_test.go | Extends public API spec tests with invalid/empty input compatibility cases. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IsCompatiblesilently returnedtruewhen both inputs were invalid semver strings —semver.Majorreturns""for unparseable input, so"" == ""evaluated totrue, causing garbage versions to be reported as compatible.Changes
pkg/semverutil/semverutil.go— Addsemver.IsValidguard before comparing majors; returnfalseimmediately if either version is invalidpkg/semverutil/semverutil_test.go/spec_test.go— Add invalid-input cases ("","not-a-version","vfoo", mixed valid/invalid)