diff --git a/pkg/plug/grpc.go b/pkg/plug/grpc.go index ae434f1..6ba590b 100644 --- a/pkg/plug/grpc.go +++ b/pkg/plug/grpc.go @@ -2,6 +2,7 @@ package plug import ( "context" + "errors" "git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/database" "git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/models" @@ -57,6 +58,18 @@ func (s *server) TaskStart(ctx context.Context, creation *gRPC.PlugTaskCreation) } span.AddEvent("Retrieved user source", trace.WithAttributes(attribute.String("user_source_id", creation.UserSourceId))) + if !userSource.AccountValidate { + err = errors.New("user is not validated") + + log.WithContext(ctx).WithError(err).WithField("task_id", id).Error("Task execution failed") + span.RecordError(err) + span.SetStatus(codes.Error, err.Error()) + + plugTaskState.TaskState = gRPC.PlugTaskState_STOPPED + + return &plugTaskState, err + } + // gRPC closes the context after the call ended. So the whole scrapping stopped without waiting // by using this method we assign a new context to each new request we get. // This can be used for example to close the context with the given id