diff --git a/pkg/contexts/ocm/cpi/repocpi/bridge_c.go b/pkg/contexts/ocm/cpi/repocpi/bridge_c.go index 322daef9a6..c4734c439c 100644 --- a/pkg/contexts/ocm/cpi/repocpi/bridge_c.go +++ b/pkg/contexts/ocm/cpi/repocpi/bridge_c.go @@ -134,6 +134,11 @@ func (c *componentAccessBridge) AddVersion(cv cpi.ComponentVersionAccess, opts * return err } + err = compdesc.Validate(cv.GetDescriptor()) + if err != nil { + return err + } + forcestore := c.IsOwned(cv) if !forcestore { eff, err := c.NewVersion(cv.GetVersion(), optionutils.AsValue(opts.Overwrite)) diff --git a/pkg/contexts/ocm/repositories/composition/repository_test.go b/pkg/contexts/ocm/repositories/composition/repository_test.go index 054b9c8125..9746088d6b 100644 --- a/pkg/contexts/ocm/repositories/composition/repository_test.go +++ b/pkg/contexts/ocm/repositories/composition/repository_test.go @@ -130,4 +130,10 @@ var _ = Describe("repository", func() { cv.GetDescriptor().Provider.Name = "acme.org" ExpectError(cl.Close()).To(MatchError(accessobj.ErrReadOnly)) }) + + It("provides early error", func() { + repo := me.NewRepository(ctx) + cv := me.NewComponentVersion(ctx, "a", "1.0") + ExpectError(repo.AddComponentVersion(cv)).To(MatchError("component.name: Does not match pattern '^[a-z][-a-z0-9]*([.][a-z][-a-z0-9]*)*[.][a-z]{2,}(/[a-z][-a-z0-9_]*([.][a-z][-a-z0-9_]*)*)+$'")) + }) })