Skip to content

fix: replace hashicorp/go-version with golang.org/x/mod/semver#532

Merged
mwbrooks merged 2 commits intomainfrom
mwbrooks-snyk-hashicorp-go-version
May 8, 2026
Merged

fix: replace hashicorp/go-version with golang.org/x/mod/semver#532
mwbrooks merged 2 commits intomainfrom
mwbrooks-snyk-hashicorp-go-version

Conversation

@mwbrooks
Copy link
Copy Markdown
Member

@mwbrooks mwbrooks commented May 8, 2026

Changelog

  • N/A

Summary

This pull request fixes a Synk license policy issue by removing the direct dependency on github.com/hashicorp/go-version (MPL-2.0 license).

We now use golang.org/x/mod/semver, which is already a direct dependency. The go-version remains as an indirect dependency through the linter tooling, but is no longer flagged by Snyk.

Preview

  • N/A

Testing

$ lack --version
# → Confirm the version is shown as "v4.0.1-XX-gXXXX" (e.g. v4.0.1-43-gbd5075f)

$ lack upgrade
# → Confirm the upgrade prompt is displayed for the dev build
# → Note: I think I may have a follow-up that disables showing the upgrade prompt on dev builds :thinking:

Requirements

The hashicorp/go-version package uses an MPL-2.0 license that triggers
Snyk license policy violations. Replace it with golang.org/x/mod/semver
(BSD-3-Clause) which is already a direct dependency.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.31%. Comparing base (96ea244) to head (f152325).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #532      +/-   ##
==========================================
+ Coverage   71.26%   71.31%   +0.04%     
==========================================
  Files         222      222              
  Lines       18698    18706       +8     
==========================================
+ Hits        13326    13341      +15     
+ Misses       4189     4186       -3     
+ Partials     1183     1179       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mwbrooks mwbrooks self-assigned this May 8, 2026
@mwbrooks mwbrooks added code health M-T: Test improvements and anything that improves code health security Use on pull requests related to security semver:patch Use on pull requests to describe the release version increment labels May 8, 2026
@mwbrooks mwbrooks added this to the Next Release milestone May 8, 2026
@mwbrooks mwbrooks marked this pull request as ready for review May 8, 2026 20:13
@mwbrooks mwbrooks requested a review from a team as a code owner May 8, 2026 20:13
Copy link
Copy Markdown
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwbrooks LGTM and will be fun to have for next release-

Comment thread internal/update/semver.go Outdated
r := ensureVPrefix(release)
c := ensureVPrefix(current)
if !semver.IsValid(r) {
return false, slackerror.New(slackerror.ErrInvalidSemVer)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ thought: This might be surfaced in verbose logs too but I'm concerned that not wrapping this error can cause a less meaningful message for debugging?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧠 I could update this with a verbose log.

I had the same concern about not wrapping the error, but there is no error returned anymore. We could manually create a descriptive error, I suppose. But the ErrInvalidSemVer already captures the core essence.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwbrooks Not blocking at all! I meant to suggest a "message" change with this but was also stumped about what'd be meaningful to include:

Suggested change
return false, slackerror.New(slackerror.ErrInvalidSemVer)
return false, slackerror.New(slackerror.ErrInvalidSemVer).
WithMessage("Value %s is not a semantic versioning", r)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! Commit f152325 adds the .WithMessage to each clause.

Comment thread internal/update/semver.go
return false, slackerror.New(slackerror.ErrInvalidSemVer)
}
return releaseVersion.GreaterThan(currentVersion), nil
return semver.Compare(r, c) > 0, nil
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 praise: RC? Release candidate?

@mwbrooks
Copy link
Copy Markdown
Member Author

mwbrooks commented May 8, 2026

Thanks for the review @zimeg! 🎉 It'll be nice to have one less dependency and to get Snyk off our back about a license policy.

@mwbrooks mwbrooks merged commit 806aa51 into main May 8, 2026
8 checks passed
@mwbrooks mwbrooks deleted the mwbrooks-snyk-hashicorp-go-version branch May 8, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code health M-T: Test improvements and anything that improves code health security Use on pull requests related to security semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants