From b7f809a907b00445ca27cbb23c1dacdd3019c5a7 Mon Sep 17 00:00:00 2001 From: Arpit Jain Date: Sun, 12 Jul 2026 07:35:04 +0900 Subject: [PATCH] fix(chart): size v3Accessor.MetaDependencies from the metadata deps Signed-off-by: Arpit Jain --- pkg/chart/common.go | 2 +- pkg/chart/common_test.go | 43 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 pkg/chart/common_test.go diff --git a/pkg/chart/common.go b/pkg/chart/common.go index be68eeb42..10718b2eb 100644 --- a/pkg/chart/common.go +++ b/pkg/chart/common.go @@ -162,7 +162,7 @@ func (r *v3Accessor) Dependencies() []Charter { } func (r *v3Accessor) MetaDependencies() []Dependency { - deps := make([]Dependency, len(r.chrt.Dependencies())) + deps := make([]Dependency, len(r.chrt.Metadata.Dependencies)) for i, c := range r.chrt.Metadata.Dependencies { deps[i] = c } diff --git a/pkg/chart/common_test.go b/pkg/chart/common_test.go new file mode 100644 index 000000000..248e97542 --- /dev/null +++ b/pkg/chart/common_test.go @@ -0,0 +1,43 @@ +/* +Copyright The Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package chart + +import ( + "testing" + + v3 "helm.sh/helm/v4/internal/chart/v3" +) + +// A v3 chart that declares a dependency in Chart.yaml but has not vendored it +// under charts/ (the normal state before "helm dependency build") must not panic +// when its metadata dependencies are read. +func TestV3AccessorMetaDependenciesUnvendored(t *testing.T) { + c := &v3.Chart{Metadata: &v3.Metadata{ + APIVersion: "v3", + Name: "x", + Version: "1.0.0", + Dependencies: []*v3.Dependency{{Name: "foo", Version: "1.0.0", Repository: "https://example.com"}}, + }} + acc, err := NewAccessor(c) + if err != nil { + t.Fatal(err) + } + deps := acc.MetaDependencies() + if len(deps) != 1 { + t.Fatalf("expected 1 meta dependency, got %d", len(deps)) + } +}