Fix CastVersion index-out-of-range panic on empty input#31
Merged
Conversation
…c removal Co-authored-by: tomodian <158877+tomodian@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issues and security concerns
Fix logic bugs, crash-inducing error handling, and error silencing
Mar 10, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes several correctness and reliability problems discovered in a codebase audit, primarily around semver comparison, panic-inducing path parsing, and errors being ignored or swallowed, so CLI failures propagate properly.
Changes:
- Correct
SemanticVersion.IsGreatercomparison logic and align tests. - Replace panic-based globbing with
files.Glob(d) ([]string, error)and propagate errors through CLI tasks. - Stop swallowing errors in
main.goandfiles.Update, with tests updated accordingly.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| parser/semver.go | Fixes inverted IsGreater logic; prevents CastVersion index panic on empty major segment. |
| parser/semver_test.go | Updates IsGreater test cases to match corrected comparison behavior. |
| files/glob.go | Changes Glob to return (paths, error) instead of panicking on invalid patterns. |
| files/glob_test.go | Updates tests to assert error returns instead of panics; adapts to new signature. |
| files/writer.go | Returns os.Stat errors instead of silently succeeding. |
| files/writer_test.go | Updates Update failure case to expect an error. |
| cmd/task/unreleased.go | Propagates files.Glob errors via CLI framework. |
| cmd/task/targets.go | Propagates files.Glob errors via CLI framework. |
| cmd/task/show.go | Propagates files.Glob errors via CLI framework. |
| cmd/task/to.go | Avoids repeated globbing by reusing results; propagates glob errors. |
| cmd/task/next.go | Removes os.Exit usage and propagates errors via CLI framework; handles glob errors. |
| main.go | Exits non-zero when cmd.Run returns an error. |
| main_test.go | Stops directly calling main (which now may os.Exit); validates cmd.Run doesn’t panic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… fix Co-authored-by: tomodian <158877+tomodian@users.noreply.github.com>
Copilot
AI
changed the title
Fix logic bugs, crash-inducing error handling, and error silencing
Fix CastVersion index-out-of-range panic on empty input
Mar 11, 2026
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.
Adds a bounds check in
CastVersionto prevent panic whenvalis empty (e.g., version string.1.2splits to["", "1", "2"]).Previous test file modifications that swapped test case values to match source changes have been reverted — test files are unchanged from the base branch.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
get.anchore.io/usr/bin/curl curl -w %{http_code} -sL -o /tmp/tmp.avv02KIrFj REDACTED -gensymabis -o /tmp/go-build3396390495/b013/symabis /opt/hostedtoolcache/go/1.24.13/x64/src/internal/chacha8rand/chacha8_amd64.s rg/toolchain@v0.--helper-status 0.1-�� 0.1-go1.26.1.lin--verbose mpile 0.1-go1.26.1.linREDACTED --gdwarf-5 ian/release/cmd/-o t 0.1-go1.26.1.lin-trimpath(dns block)If you need me to access, download, or install something from one of these locations, you can either:
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.