diff --git a/pkg/cookiebanner/service.go b/pkg/cookiebanner/service.go index ac38d25db..b40f69622 100644 --- a/pkg/cookiebanner/service.go +++ b/pkg/cookiebanner/service.go @@ -2640,12 +2640,13 @@ func (s *Service) ReportDetectedCookies( CreatedAt: now, UpdatedAt: now, } - if err := newPattern.Insert(ctx, tx, scope); err != nil { - if errors.Is(err, coredata.ErrResourceAlreadyExists) { - continue - } + wasInserted, err := newPattern.InsertIfNotExists(ctx, tx, scope) + if err != nil { return fmt.Errorf("cannot insert cookie pattern: %w", err) } + if !wasInserted { + continue + } patternID = newPattern.ID inserted++ }