diff --git a/syft/format/syftjson/model/source.go b/syft/format/syftjson/model/source.go index 11cf53bd190..46ae00f93ef 100644 --- a/syft/format/syftjson/model/source.go +++ b/syft/format/syftjson/model/source.go @@ -58,7 +58,8 @@ func (s *Source) UnmarshalJSON(b []byte) error { func unpackSrcMetadata(s *Source, unpacker sourceUnpacker) error { rt := sourcemetadata.ReflectTypeFromJSONName(s.Type) if rt == nil { - return fmt.Errorf("unable to find source metadata type=%q", s.Type) + // in cases where we are converting from an SBOM without any source information, we don't want this to be fatal + return nil } val := reflect.New(rt).Interface() diff --git a/syft/format/syftjson/model/source_test.go b/syft/format/syftjson/model/source_test.go index c462debe7ca..ce8b5bf0464 100644 --- a/syft/format/syftjson/model/source_test.go +++ b/syft/format/syftjson/model/source_test.go @@ -22,6 +22,15 @@ func TestSource_UnmarshalJSON(t *testing.T) { expected *Source wantErr require.ErrorAssertionFunc }{ + { + name: "empty", + input: []byte(`{ + "id": "", + "type": "", + "metadata": null + }`), + expected: &Source{}, + }, { name: "directory", input: []byte(`{