Skip to content

loosen version verification - #3750

Merged
ucodery merged 2 commits into
masterfrom
jeremyp/loose-version
Sep 26, 2025
Merged

ucodery merged 2 commits into
masterfrom
jeremyp/loose-version

Conversation

@ucodery

@ucodery ucodery commented Sep 24, 2025 •

Copy link
Copy Markdown
Contributor

This change comes down to removing the regex checks on user-supplied version string. They were overly constraining. Now everything is allowed to at least be attempted on the platform. If it really can't be a version, then an error will come back from the platform; probably a solve error.

mitchell-as
mitchell-as previously approved these changes Sep 25, 2025

@mitchell-as mitchell-as left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This sounds reasonable to me.

Comment on lines -286 to +283
if versionRe.MatchString(version) && req.Resolved.ingredient != nil {
if req.Resolved.ingredient != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The regex does seem like it was overkill here, but reading this code I think we still want to check if version is non-empty? In most cases we run state install without a specific version, in which case this it doesn't seem like we should run this logic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmm, I ran a single test of state install namespace:name (no dynamic, no version) and that worked. But I would be okay to check for the empty string.

func isExactVersion(version string) bool {
return versionRe.MatchString(version)
func isRangeVersion(version string) bool {
return strings.Contains(version, "=") || strings.Contains(version, "<") || strings.Contains(version, ">")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

strings.Contains(version, "=")

This doesn't indicate a range version does it? I suppose you could have >= but = alone could also apply to ==1.0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no, = alone doesn't indicate a version range, but == is a range, as are >=, <=, !=, and others that are less common like ~=. It is just an indicator, as = is never legal in a concrete version identifier.

these three characters are the minimum sufficient to determine if any of the universal version range operators are being used.

@Naatan Naatan Sep 26, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry I don't think I'm following, let me ask a different way;

Wouldn't isRangeVersion('==1.0') return true even though it should be false?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That one is a bit different, true, but IMO it does and should return true. There is a distinction between ==1.0 and 1.0, though maybe not to the state tool. The former is a constraint and does represent a range, but a range that includes only one version; the latter is a versions string.

So the practical reason to send even ==1.0 to the back end is that == should not be part of the version string. Sending it to the platform means we don't have to special case this one operator for stripping. This is good, as version strings get complex across so many ecosystems, e.g. in Rust = is the eq operator, not ==.

Comment thread readme.md Resolved
Co-authored-by: Nathan Rijksen <nathanr@activestate.com>

@Naatan Naatan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please see my latest comment, I'll defer to you if that's worth addressing as you understand these version strings better than I do.

@ucodery
ucodery merged commit c18b4c8 into master Sep 26, 2025
@ucodery
ucodery deleted the jeremyp/loose-version branch September 26, 2025 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants