Skip to content

fix(autodiscovery/golang): correctly handle pseudo version#8698

Merged
olblak merged 7 commits into
updatecli:mainfrom
olblak:fix_autodiscovery_golang_pseudoVersion
May 14, 2026
Merged

fix(autodiscovery/golang): correctly handle pseudo version#8698
olblak merged 7 commits into
updatecli:mainfrom
olblak:fix_autodiscovery_golang_pseudoVersion

Conversation

@olblak

@olblak olblak commented May 14, 2026

Copy link
Copy Markdown
Member

Fix pseudo version in golang autodiscovery.

If a go module uses a pseudo version then Updatecli override the version filter to handle it.
A pseudo version looks like "v0.0.0-20260209031235-2402fdf4a9ed"

Test

To test this pull request, you can run the following commands:

cd pkg/plugins/autodiscovery/golang/
go test

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

Tradeoff

Potential improvement

olblak added 2 commits May 14, 2026 15:51
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak added bug Something isn't working autodiscovery All things related to the autodiscovery feature labels May 14, 2026
@olblak olblak requested a review from Copilot May 14, 2026 13:56

Copilot AI 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.

Pull request overview

This PR aims to improve the Golang autodiscovery pipeline generation so that modules pinned to Go pseudo-versions don’t break version filtering and can still be updated correctly.

Changes:

  • Added pseudo-version detection via isPseudoVersion (regex-based).
  • Updated Golang dependency autodiscovery to override the version filter when a pseudo-version is detected.
  • Extended autodiscovery tests to cover pseudo-version scenarios.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
pkg/plugins/autodiscovery/golang/utils.go Adds pseudo-version detection helper and regex.
pkg/plugins/autodiscovery/golang/dependency.go Overrides versionfilter kind/pattern when a dependency (or replace) uses a pseudo-version.
pkg/plugins/autodiscovery/golang/utils_test.go Updates search expectations and adds unit tests for pseudo-version detection.
pkg/plugins/autodiscovery/golang/main_test.go Adds an autodiscovery fixture test for pseudo-version manifest generation.
Comments suppressed due to low confidence (1)

pkg/plugins/autodiscovery/golang/dependency.go:178

  • Same as above for replace modules: kind is switched to latest but pattern is set to "". With kind: latest, the filter logic expects pattern: latest; otherwise it can fail to resolve a version when the proxy returns a list. Set the pattern to latest (or use a semver "latest" pattern) to avoid producing non-functional manifests for replaced modules.
				goModuleVersionPattern := g.versionFilter.Pattern
				goModuleVersionKind := g.versionFilter.Kind
				switch isPseudoVersion(replace.NewVersion) {
				case false:
					goModuleVersionPattern, err = g.versionFilter.GreaterThanPattern(replace.NewVersion)
					if err != nil {
						logrus.Debugf("skipping golang module %q due to: %s", replace.NewPath, err)
						continue
					}

				case true:
					// If the new version is a pseudo-version,
					// we cannot apply a version filter pattern as
					// golang registry will only return one version for this module.

					logrus.Debugf("Module %q uses a pseudo-version %q, so ignoring version filter for this module as the registry will only return one version", replace.NewPath, replace.NewVersion)

					goModuleVersionKind = "latest"
					goModuleVersionPattern = ""
				}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/plugins/autodiscovery/golang/utils.go Outdated
Comment thread pkg/plugins/autodiscovery/golang/dependency.go
Comment thread pkg/plugins/autodiscovery/golang/utils_test.go
Comment thread pkg/plugins/autodiscovery/golang/main_test.go
Comment thread pkg/plugins/autodiscovery/golang/main_test.go
Comment thread pkg/plugins/autodiscovery/golang/utils_test.go
olblak and others added 4 commits May 14, 2026 16:08
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak enabled auto-merge (squash) May 14, 2026 15:35
@olblak olblak merged commit 1f1f989 into updatecli:main May 14, 2026
7 checks passed
@olblak olblak deleted the fix_autodiscovery_golang_pseudoVersion branch May 14, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autodiscovery All things related to the autodiscovery feature bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants