Repository navigation
Fix numeric prerelease comparisons with leading zeroes - #228
Closed
xianjianlf2 wants to merge 1 commit into
Closed
xianjianlf2 wants to merge 1 commit into
xianjianlf2 wants to merge 1 commit into
Conversation
tgross
requested changes
Oct 12, 2026
Member
There was a problem hiding this comment.
Generally speaking we're not interested in getting a pile of LLM-generated fixes that aren't motivated by specific problems in HashiCorp products or spec compliance issues. How do you suggest this changeset interacts with the following bit from section 9 of the semver spec:
Numeric identifiers MUST NOT include leading zeroes.
Especially given that you changed the docstring in the process.
Member
|
If your response to questions on a PR is to close it without comment, please do us a favor and don't bother opening more slop PRs. We're really only interested in developing human contributors, not encouraging LLM slop. |
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.
Description
NewVersion accepts numeric prerelease identifiers with leading zeroes, but the numeric comparison uses their untrimmed lengths. This makes 1.0.0-001 compare greater than 1.0.0-2, and 1.0.0-01 compare unequal to 1.0.0-1.
Trim leading zeroes before comparing numeric identifiers. This preserves support for values larger than int64 without changing parsing or the original version strings.
Related Issue
No linked issue.
How Has This Been Tested?
Regression tests cover equal values, all-zero identifiers, ordering, and values larger than int64 in both comparison directions. Five of the seven cases fail before the fix.
Passing after the fix:
Code, tests, and this draft were prepared with OpenAI Codex.