Skip to content

Commit 7c2956e

Browse files
committed
fix(populator): put correct argument in decode call
Fix a panic in the populator code caused by giving the wrong argument to the decodeFile function. Also, add a better panic message indicating programming error.
1 parent aa1652d commit 7c2956e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/registry/populator.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (i *DirectoryPopulator) Populate() error {
4444
// manifests of the bundle should be loaded into the database.
4545
annotationsFile := &AnnotationsFile{}
4646
for _, f := range files {
47-
err = decodeFile(filepath.Join(metadata, f.Name()), err)
47+
err = decodeFile(filepath.Join(metadata, f.Name()), annotationsFile)
4848
if err != nil || *annotationsFile == (AnnotationsFile{}) {
4949
continue
5050
}
@@ -239,6 +239,10 @@ func translateAnnotationsIntoPackage(annotations *AnnotationsFile, csv *ClusterS
239239

240240
// decodeFile decodes the file at a path into the given interface.
241241
func decodeFile(path string, into interface{}) error {
242+
if into == nil {
243+
panic("programmer error: decode destination must be instantiated before decode")
244+
}
245+
242246
fileReader, err := os.Open(path)
243247
if err != nil {
244248
return fmt.Errorf("unable to read file %s: %s", path, err)

0 commit comments

Comments
 (0)