Skip to content

Conversation

@kevinleturc
Copy link
Contributor

@kevinleturc kevinleturc commented Dec 19, 2025

I'm trying to use updatecli on a maven project to update only its parent version.

The parent dependency is released in two formats, a three digits one and a two digits one.
I want updatecli to update the parent version with the two digits format, so I used the regex versionfilter kind:

---
name: "Maven nuxeo-parent update"

autodiscovery:
  crawlers:
    maven:
      only:
        - groupIds:
            - org.nuxeo
          artifactIds:
            nuxeo-parent: ""
      versionfilter:
        kind: regex
        pattern: '^\d+.\d+$'

During my tests of this configuration I was not able to get an update difference and notice this error in debug logs:

DEBUG: parsing file "pom.xml"
DEBUG: template: manifest:23:19: executing "manifest" at <.SourceVersionFilterRegex>: can't evaluate field SourceVersionFilterRegex in type struct { ActionID string; ManifestName string; ConditionID string; ConditionGroupID string; ConditionGroupIDName string; ConditionGroupIDPath string; ConditionGroupIDValue string; ConditionArtifactID string; ConditionArtifactIDName string; ConditionArtifactIDPath string; ConditionArtifactIDValue string; SourceID string; SourceName string; SourceKind string; SourceGroupID string; SourceArtifactID string; SourceRepositories []string; SourceVersionFilterKind string; SourceVersionFilterPattern string; TargetID string; TargetName string; TargetXMLPath string; File string; ScmID string }
Manifest detected: 0

It happens only on 0.112.0, everything seems to work on 0.111.0.

I had a look to the maven autodiscovery plugin that causes this error and noticed that the template would render the regex field in this context:

      versionfilter:
        kind: '{{ .SourceVersionFilterKind }}'
        pattern: '{{ .SourceVersionFilterPattern }}'
{{- if or (eq .SourceVersionFilterKind "regex") (eq .SourceVersionFilterKind "regex/semver") (eq .SourceVersionFilterKind "regex/time") }}
        regex: '{{ .SourceVersionFilterRegex }}'
{{- end }}

According to the maven autodiscoverry plugin documentation https://www.updatecli.io/docs/plugins/autodiscovery/maven/, the regex field should be set when regex/semver and regex/time are used.
The current code includes the regex field with the regex kind, the first commit of this PR fixes that to respect the documentation for all autodiscovery plugins.

The second commit is about adding the link between the autodiscovery plugin configuration and the templating by giving versionFilterRegex parameters to template rendering.

Additional Information

Potential improvement

There're default in some autodiscovery plugins that I set Regex to * which shouldn't be a problem for most usage as it is printed only for regex/semver and regex/time Kind. But there's might be room for improvements.

@kevinleturc kevinleturc marked this pull request as ready for review December 19, 2025 12:28
@olblak
Copy link
Member

olblak commented Dec 20, 2025

Thanks for the pull request.
I'll review it as soon as possible

Signed-off-by: Olblak <me@olblak.com>
@olblak olblak added the bug Something isn't working label Dec 20, 2025
@olblak olblak requested a review from Copilot December 20, 2025 20:40
@olblak
Copy link
Member

olblak commented Dec 20, 2025

Thanks for the pull request, while reviewing, I noticed some missing part from
#7140

I didn't test everything

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a critical template rendering bug in autodiscovery plugins where the SourceVersionFilterRegex field was being referenced in templates without being properly defined in the template context, causing template execution errors when using versionfilter with kind: regex.

The PR implements two key changes:

  • Removes the incorrect "regex" kind from conditional checks in manifest templates (only "regex/semver" and "regex/time" should render the regex field)
  • Adds the VersionFilterRegex parameter to template data structures across all autodiscovery plugins

Reviewed changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/plugins/autodiscovery/updatecli/policies.go Adds SourceVersionFilterRegex field initialization and population in template data
pkg/plugins/autodiscovery/updatecli/manifestTemplate.go Removes "regex" from conditional check for regex field rendering
pkg/plugins/autodiscovery/terragrunt/modules.go Adds VersionFilterRegex field to template parameters
pkg/plugins/autodiscovery/terragrunt/manifest_template.go Adds conditional rendering of regex field for regex/semver and regex/time kinds
pkg/plugins/autodiscovery/terraform/providers.go Adds VersionFilterRegex field to template parameters
pkg/plugins/autodiscovery/terraform/manifest_template.go Adds conditional rendering of regex field for regex/semver and regex/time kinds
pkg/plugins/autodiscovery/precommit/manifestTemplate.go Removes "regex" from conditional checks for regex field rendering (2 occurrences)
pkg/plugins/autodiscovery/precommit/dependency.go Adds versionRegex initialization and SourceVersionFilterRegex to template data
pkg/plugins/autodiscovery/npm/manifestTemplate.go Removes "regex" from conditional check and adds SourceVersionFilterRegex field
pkg/plugins/autodiscovery/npm/dependency.go Adds sourceVersionFilterRegex initialization and population in multiple code paths
pkg/plugins/autodiscovery/nomad/manifestTemplate.go Removes "regex" from conditional checks for regex field rendering (2 occurrences)
pkg/plugins/autodiscovery/nomad/dockerDriver.go Adds versionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/maven/manifestTemplate.go Removes "regex" from conditional check for regex field rendering
pkg/plugins/autodiscovery/maven/dependencyParentPom.go Adds sourceVersionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/maven/dependency.go Adds sourceVersionFilterRegex field to struct (missing conditional assignment - see bug comment)
pkg/plugins/autodiscovery/kubernetes/manifestTemplate.go Removes "regex" from conditional checks for regex field rendering (2 occurrences)
pkg/plugins/autodiscovery/kubernetes/containers.go Adds versionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/ko/manifestTemplate.go Removes "regex" from conditional checks for regex field rendering (2 occurrences)
pkg/plugins/autodiscovery/ko/containers.go Adds versionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/helmfile/releases.go Adds sourceVersionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/helmfile/manifestTemplate.go Removes "regex" from conditional check for regex field rendering
pkg/plugins/autodiscovery/helm/dependencyManifest.go Removes "regex" from conditional check for regex field rendering
pkg/plugins/autodiscovery/helm/dependencies.go Adds sourceVersionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/helm/containerManifest.go Removes "regex" from conditional check and adds regex field rendering for digest template
pkg/plugins/autodiscovery/helm/container.go Adds versionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/golang/manifestTemplate.go Removes "regex" from conditional checks for regex field rendering (3 occurrences)
pkg/plugins/autodiscovery/golang/dependency.go Updates function signatures and adds versionFilterRegex to all module manifest functions (parameter order issue - see bug comment)
pkg/plugins/autodiscovery/githubaction/workflowGHAManifest.go Adds versionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/githubaction/workflowDockerManifest.go Adds versionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/githubaction/templateGHAGitea.go Adds conditional rendering of regex field for regex/semver and regex/time kinds (3 occurrences)
pkg/plugins/autodiscovery/githubaction/templateGHAGitHub.go Adds conditional rendering of regex field for regex/semver and regex/time kinds (3 occurrences)
pkg/plugins/autodiscovery/flux/ociRepositoryManifests.go Adds versionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/flux/ociRepositoryManifestTemplate.go Removes "regex" from conditional checks for regex field rendering (2 occurrences)
pkg/plugins/autodiscovery/flux/main.go Adds defaultVersionFilterRegex constant
pkg/plugins/autodiscovery/flux/helmreleaseManifests.go Adds sourceVersionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/flux/helmreleaseManifestTemplate.go Removes "regex" from conditional check for regex field rendering
pkg/plugins/autodiscovery/fleet/manifestTemplate.go Removes "regex" from conditional check for regex field rendering
pkg/plugins/autodiscovery/fleet/dependencies.go Adds sourceVersionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/dockerfile/manifestTemplate.go Removes "regex" from conditional checks for regex field rendering (2 occurrences)
pkg/plugins/autodiscovery/dockercompose/manifestTemplate.go Removes "regex" from conditional checks for regex field rendering (2 occurrences)
pkg/plugins/autodiscovery/dockercompose/compose.go Adds versionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/cargo/dependencyManifest.go Adds conditional rendering of regex field for regex/semver and regex/time kinds
pkg/plugins/autodiscovery/cargo/dependencies.go Adds sourceVersionFilterRegex initialization and population in template data
pkg/plugins/autodiscovery/argocd/manifestTemplate.go Removes "regex" from conditional check for regex field rendering
pkg/plugins/autodiscovery/argocd/application.go Adds sourceVersionFilterRegex initialization and population in template data
Comments suppressed due to low confidence (1)

pkg/plugins/autodiscovery/maven/dependency.go:115

  • The sourceVersionFilterRegex should be set inside this conditional block, similar to how it's done in dependencyParentPom.go. Without this, when a custom VersionFilter is specified, the regex value won't be updated and will remain at its default value from line 107, potentially causing incorrect filtering behavior.

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

Signed-off-by: Olblak <me@olblak.com>
@olblak olblak requested a review from loispostula December 20, 2025 20:52
@kevinleturc
Copy link
Contributor Author

Copilot is right about:

pkg/plugins/autodiscovery/maven/dependency.go:115

The sourceVersionFilterRegex should be set inside this conditional block, similar to how it's done in dependencyParentPom.go. Without this, when a custom VersionFilter is specified, the regex value won't be updated and will remain at its default value from line 107, potentially causing incorrect filtering behavior.

I'll push an addition to this file.

@olblak
Copy link
Member

olblak commented Dec 21, 2025

Thanks for the quick fix.
The fix looks good to me, I am for a final review from @loispostula
If he doesn't have the time in the coming week then I'll merge it and trigger a release

Copy link
Contributor

@loispostula loispostula left a comment

Choose a reason for hiding this comment

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

Good catch and good fix, thanks a lot

@olblak olblak merged commit 126a6cb into updatecli:main Dec 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants