Skip to content

fix: default the version of release dependencies that omit it - #2892

Merged
yxxhero merged 1 commit into
helmfile:mainfrom
Cayan:fix/adhoc-dependency-default-version
Nov 12, 2026
Merged

yxxhero merged 1 commit into
helmfile:mainfrom
Cayan:fix/adhoc-dependency-default-version

Conversation

@Cayan

@Cayan Cayan commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

The docs show a local ad-hoc dependency without version, but helmfile template on it fails:

Error: dependency "child" has an invalid version/constraint format: improper constraint: ""

PrepareChartify passes the empty version to chartify, which writes it to the generated Chart.yaml. Helm rejects an empty constraint in semver.NewConstraint(d.Version) (internal/resolver/resolver.go). The same happens for a dependency from a chart repository.

This change fills in a default when version is empty:

  • >=0.0.0-0 for a local chart or one fetched with go-getter. Helm checks a file:// dependency against the single version in its Chart.yaml. A constraint without a prerelease part does not match prereleases (Masterminds/semver), so * would still fail for a chart at 1.2.3-rc.1 with can't get a valid version.
  • * for a repository or OCI chart, so Helm picks the latest version that is not a prerelease, as chartify already does for the older string form of dependencies.

An explicit version reaches chartify unchanged. The dependencies section of docs/advanced-features.md describes the defaults.

Tests:

  • TestPrepareChartify_DependencyDefaultVersion in pkg/state/helmx_test.go checks the version chartify receives for repository, OCI, local and go-getter dependencies with and without version. On main the four cases without version get "".
  • Snapshot case issue_1407_adhoc_dep_without_version runs helmfile template with a repository dependency (myrepo/raw) and a local prerelease dependency (0.2.0-rc.1), neither with version. It renders raw 0.1.0 and the prerelease; with the main binary it fails with the error above. It passes with Helm v3.18.6, v3.22.1 and v4.3.1.

helmfile template on a local chart with one dependency and no version:

dependency main this branch
local chart 1.2.3 improper constraint error renders child-1.2.3
local chart 1.2.3-rc.1 improper constraint error renders childrc-1.2.3-rc.1
repository with 1.2.3 and 1.3.0-rc.1 improper constraint error renders child-1.2.3

helm/helm#10096 ("Make version optional for local chart dependencies") is still open, so Helm itself still needs a constraint here.

Fixes the missing version case reported in #1407. The issue also reports "found in Chart.yaml, but missing in charts/ directory" with an explicit version; that does not reproduce with helmfile template on main (Helm 4.2.3), and this change does not touch it.

Helm rejects an empty version constraint, so a release dependency without `version` failed to
render. Remote charts now get "*" and local charts ">=0.0.0-0", which also accepts a prerelease
local chart. An explicit version is passed through unchanged.

Signed-off-by: Cayan <[email protected]>

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.

🟢 Approval recommended

No active review issues block the dependency-version defaulting change.

No open issues 🎉

What changed in this PR

Fixes the missing dependency-version case in #1407 by supplying valid constraints before passing ad-hoc dependencies to chartify. Explicit versions remain unchanged.

Changes:

  • Defaults local and go-getter dependencies to >=0.0.0-0, allowing prereleases, and repository/OCI dependencies to *.
  • Adds unit tests and Helm 3/4 snapshots covering omitted versions.
  • Documents the default constraints.
File Description
test/​e2e/​template/​helmfile/​testdata/​snapshot/​issue_1407_adhoc_dep_without_version/​output.yaml Expected Helm 3 rendering.
test/​e2e/​template/​helmfile/​testdata/​snapshot/​issue_1407_adhoc_dep_without_version/​output-helm4.yaml Expected Helm 4 rendering.
test/​e2e/​template/​helmfile/​testdata/​snapshot/​issue_1407_adhoc_dep_without_version/​input.yaml.gotmpl Exercises repository and local dependencies without versions.
test/​e2e/​template/​helmfile/​testdata/​snapshot/​issue_1407_adhoc_dep_without_version/​config.yaml Configures the snapshot repository and template command.
test/​e2e/​template/​helmfile/​testdata/​snapshot/​issue_1407_adhoc_dep_without_version/​chart/​rc/​templates/​resources.yaml Renders the local dependency’s test resources.
test/​e2e/​template/​helmfile/​testdata/​snapshot/​issue_1407_adhoc_dep_without_version/​chart/​rc/​Chart.yaml Defines the local prerelease chart fixture.
pkg/​state/​helmx.go Applies source-aware defaults to empty dependency versions.
pkg/​state/​helmx_test.go Tests defaults and preservation of explicit versions.
docs/​advanced-features.md Explains optional versions and their defaults.

Review effort: Balanced

@yxxhero
yxxhero merged commit 2ae1e17 into helmfile:main Nov 12, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants