From 69efc0d4fbcc143e0b196253f6e82808aaa57fc3 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 29 Jul 2025 15:37:57 -0400 Subject: [PATCH] Handle messy index files Signed-off-by: Matt Farina --- pkg/repo/index.go | 5 +++-- pkg/repo/index_test.go | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/repo/index.go b/pkg/repo/index.go index c26d7581c..4de8bb463 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -355,7 +355,8 @@ func loadIndex(data []byte, source string) (*IndexFile, error) { for name, cvs := range i.Entries { for idx := len(cvs) - 1; idx >= 0; idx-- { if cvs[idx] == nil { - slog.Warn("skipping loading invalid entry for chart %q from %s: empty entry", name, source) + slog.Warn(fmt.Sprintf("skipping loading invalid entry for chart %q from %s: empty entry", name, source)) + cvs = append(cvs[:idx], cvs[idx+1:]...) continue } // When metadata section missing, initialize with no data @@ -366,7 +367,7 @@ func loadIndex(data []byte, source string) (*IndexFile, error) { cvs[idx].APIVersion = chart.APIVersionV1 } if err := cvs[idx].Validate(); ignoreSkippableChartValidationError(err) != nil { - slog.Warn("skipping loading invalid entry for chart %q %q from %s: %s", name, cvs[idx].Version, source, err) + slog.Warn(fmt.Sprintf("skipping loading invalid entry for chart %q %q from %s: %s", name, cvs[idx].Version, source, err)) cvs = append(cvs[:idx], cvs[idx+1:]...) } } diff --git a/pkg/repo/index_test.go b/pkg/repo/index_test.go index d40719b12..7810d3ac0 100644 --- a/pkg/repo/index_test.go +++ b/pkg/repo/index_test.go @@ -68,6 +68,7 @@ entries: grafana: - apiVersion: v2 name: grafana + - null foo: - bar: