From 0070352623e60ae15b9eeb81f8b49522e1dd581d Mon Sep 17 00:00:00 2001 From: SoXX Date: Tue, 27 Aug 2024 09:35:25 +0200 Subject: [PATCH] fix: upsertSource function now returning the correct source after finding it or creating it --- pkg/plug/source.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/plug/source.go b/pkg/plug/source.go index 6a19228..7afbd22 100644 --- a/pkg/plug/source.go +++ b/pkg/plug/source.go @@ -14,7 +14,7 @@ func upsertSource(ctx context.Context, source models.Source) (models.Source, err var err error - source, err = database.GetSourceByDomain(ctx, source.Domain) + localSource, err := database.GetSourceByDomain(ctx, source.Domain) if err != nil { if err.Error() == "Database error: NoDataFound" { span.AddEvent("No Source found, initializing source") @@ -32,6 +32,8 @@ func upsertSource(ctx context.Context, source models.Source) (models.Source, err span.AddEvent("Source created") log.WithContext(ctx).WithError(err).WithField("source_domain", source.Domain).WithField("source_id", source.ID).Info("Source created!") + return source, nil + } else { span.RecordError(err) span.SetStatus(codes.Error, err.Error()) @@ -40,5 +42,5 @@ func upsertSource(ctx context.Context, source models.Source) (models.Source, err } } - return source, nil + return localSource, nil }