Summary
When using Helm, if you declare a dependency but do not specify a version constraint in that dependency declaration, you get an error which doesn't tell you what is really wrong. Instead it says that a dependency has an "improper" constraint, which isn't true (it doesn't have any constraint at all, because of the missing key). After an hour of googling and experimentation, you finally learn that, actually, it was just a missing key.
Suggested fix
Change error message from:
Error: dependency "some-sub-chart" has an invalid version/constraint format: improper constraint:
helm.go:84: [debug] improper constraint:
dependency "some-sub-chart" has an invalid version/constraint format
To:
Error: dependency "some-sub-chart" has an invalid version/constraint format: missing "version" key in dependency definition
helm.go:84: [debug] improper constraint:
dependency "some-sub-chart" has an invalid version/constraint format: missing "version" key in dependency definition
Reproducing the bug
Make a chart like this:
# Chart.yaml
apiVersion: v2
name: foobar
version: 1.0.0
dependencies:
- name: some-sub-chart
And a sub-chart:
# charts/some-sub-chart/Charts.yaml
apiVersion: v2
name: some-sub-chart
version: 1.0.0
Try to check dependencies in the parent:
$ helm dependency update --skip-refresh --debug
Error: dependency "some-sub-chart" has an invalid version/constraint format: improper constraint:
helm.go:84: [debug] improper constraint:
dependency "some-sub-chart" has an invalid version/constraint format
helm.sh/helm/v3/internal/resolver.(*Resolver).Resolve
helm.sh/helm/v3/internal/resolver/resolver.go:63
helm.sh/helm/v3/pkg/downloader.(*Manager).resolve
helm.sh/helm/v3/pkg/downloader/manager.go:236
helm.sh/helm/v3/pkg/downloader.(*Manager).Update
helm.sh/helm/v3/pkg/downloader/manager.go:195
main.newDependencyUpdateCmd.func1
helm.sh/helm/v3/cmd/helm/dependency_update.go:74
github.com/spf13/cobra.(*Command).execute
github.com/spf13/cobra@v1.5.0/command.go:872
github.com/spf13/cobra.(*Command).ExecuteC
github.com/spf13/cobra@v1.5.0/command.go:990
github.com/spf13/cobra.(*Command).Execute
github.com/spf13/cobra@v1.5.0/command.go:918
main.main
helm.sh/helm/v3/cmd/helm/helm.go:83
runtime.main
runtime/proc.go:250
runtime.goexit
runtime/asm_arm64.s:1172
Then modify the parent chart:
# Chart.yaml
apiVersion: v2
name: foobar
version: 1.0.0
dependencies:
- name: some-sub-chart
version: 1.0.0
Run again from parent:
$ helm dependency update --skip-refresh --debug
Saving 1 charts
Dependency some-sub-chart did not declare a repository. Assuming it exists in the charts directory
Deleting outdated charts
Debugging
Output of helm version:
$ helm version
version.BuildInfo{Version:"v3.10.2", GitCommit:"50f003e5ee8704ec937a756c646870227d7c8b58", GitTreeState:"clean", GoVersion:"go1.19.3"}
Output of kubectl version:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.14", GitCommit:"0f77da5bd4809927e15d1658fb4aa8f13ad890a5", GitTreeState:"clean", BuildDate:"2022-06-15T14:17:29Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"darwin/arm64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.14-gke.4300", GitCommit:"348bdc1040d273677ca07c0862de867332eeb3a1", GitTreeState:"clean", BuildDate:"2022-08-17T09:22:54Z", GoVersion:"go1.16.15b7", Compiler:"gc", Platform:"linux/amd64"}
Cloud Provider/Platform (AKS, GKE, Minikube etc.): GKE
Summary
When using Helm, if you declare a dependency but do not specify a version constraint in that dependency declaration, you get an error which doesn't tell you what is really wrong. Instead it says that a dependency has an "improper" constraint, which isn't true (it doesn't have any constraint at all, because of the missing key). After an hour of googling and experimentation, you finally learn that, actually, it was just a missing key.
Suggested fix
Change error message from:
To:
Reproducing the bug
Make a chart like this:
And a sub-chart:
Try to check dependencies in the parent:
Then modify the parent chart:
Run again from parent:
Debugging
Output of
helm version:Output of
kubectl version:Cloud Provider/Platform (AKS, GKE, Minikube etc.): GKE