@@ -108,10 +108,14 @@ func (b *remoteChartBuilder) Build(_ context.Context, ref Reference, p string, o
108108 // - BuildOptions.Force is False
109109 if opts .CachedChart != "" && ! opts .Force {
110110 if curMeta , err := LoadChartMetadataFromArchive (opts .CachedChart ); err == nil {
111- if result .Name == curMeta .Name && result .Version == curMeta .Version {
112- result .Path = opts .CachedChart
113- result .ValuesFiles = opts .GetValuesFiles ()
114- return result , nil
111+ // If the cached metadata is corrupt, we ignore its existence
112+ // and continue the build
113+ if err = curMeta .Validate (); err == nil {
114+ if result .Name == curMeta .Name && result .Version == curMeta .Version {
115+ result .Path = opts .CachedChart
116+ result .ValuesFiles = opts .GetValuesFiles ()
117+ return result , nil
118+ }
115119 }
116120 }
117121 }
@@ -207,9 +211,13 @@ func validatePackageAndWriteToPath(reader io.Reader, out string) error {
207211 if err = tmpFile .Close (); err != nil {
208212 return err
209213 }
210- if _ , err = LoadChartMetadataFromArchive (tmpFile .Name ()); err != nil {
214+ meta , err := LoadChartMetadataFromArchive (tmpFile .Name ())
215+ if err != nil {
211216 return fmt .Errorf ("failed to load chart metadata from written chart: %w" , err )
212217 }
218+ if err = meta .Validate (); err != nil {
219+ return fmt .Errorf ("failed to validate metadata of written chart: %w" , err )
220+ }
213221 if err = fs .RenameWithFallback (tmpFile .Name (), out ); err != nil {
214222 return fmt .Errorf ("failed to write chart to file: %w" , err )
215223 }
0 commit comments