@@ -28,6 +28,7 @@ import (
28
28
"os"
29
29
"path"
30
30
"sort"
31
+ "strings"
31
32
"sync"
32
33
33
34
"github.com/Masterminds/semver/v3"
@@ -91,10 +92,14 @@ func IndexFromBytes(b []byte) (*repo.IndexFile, error) {
91
92
if cvs [idx ] == nil {
92
93
continue
93
94
}
95
+ // When metadata section missing, initialize with no data
96
+ if cvs [idx ].Metadata == nil {
97
+ cvs [idx ].Metadata = & chart.Metadata {}
98
+ }
94
99
if cvs [idx ].APIVersion == "" {
95
100
cvs [idx ].APIVersion = chart .APIVersionV1
96
101
}
97
- if err := cvs [idx ].Validate (); err != nil {
102
+ if err := cvs [idx ].Validate (); ignoreSkippableChartValidationError ( err ) != nil {
98
103
cvs = append (cvs [:idx ], cvs [idx + 1 :]... )
99
104
}
100
105
}
@@ -501,3 +506,23 @@ func jsonOrYamlUnmarshal(b []byte, i interface{}) error {
501
506
}
502
507
return yaml .UnmarshalStrict (b , i )
503
508
}
509
+
510
+ // ignoreSkippableChartValidationError inspect the given error and returns nil if
511
+ // the error isn't important for index loading
512
+ //
513
+ // In particular, charts may introduce validations that don't impact repository indexes
514
+ // And repository indexes may be generated by older/non-complient software, which doesn't
515
+ // conform to all validations.
516
+ func ignoreSkippableChartValidationError (err error ) error {
517
+ verr , ok := err .(chart.ValidationError )
518
+ if ! ok {
519
+ return err
520
+ }
521
+
522
+ // https://github.com/helm/helm/issues/12748 (JFrog repository strips alias field)
523
+ if strings .HasPrefix (verr .Error (), "validation: more than one dependency with name or alias" ) {
524
+ return nil
525
+ }
526
+
527
+ return err
528
+ }
0 commit comments