umbraco / Umbraco.Deploy.Issues

1 stars 0 forks source link

Error trying to transfer/restore content #197

Closed dzilleb5 closed 9 months ago

dzilleb5 commented 9 months ago

Hi,

we are having problems deploying or restoring content from one instance to another.

We are using following versions:

When trying to deploy content we receive the following error:

The source environment has thrown a Umbraco.Deploy.Infrastructure.Exceptions.RemoteApiException with message: The remote API has thrown an exception. It might have been caused by an inner System.AggregateException with message: One or more errors occurred. (Wasn't able to get an UmbracoContext)

What is strange that on the target envoirenment I can see in the History that the node was published. But the content changes were not transferred.

Following exception is thrown: EXCEPTION:

Umbraco.Deploy.Infrastructure.Exceptions.RemoteApiException: The remote API has thrown an exception. at Umbraco.Deploy.Infrastructure.Http.DeployHttpClient.SucceedOrThrow(HttpResponseMessage result, CancellationToken token) at Umbraco.Deploy.Infrastructure.Http.DeployHttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken token) at Umbraco.Deploy.Infrastructure.Http.DeployHttpClient.SendAsync(HttpRequestMessage request, CancellationToken token) at Umbraco.Deploy.Infrastructure.Environments.RemoteUmbracoEnvironment.WaitAction(Guid sessionId, JsonSerializerSettings serializerSettings, String action, CancellationToken token) at Umbraco.Deploy.Infrastructure.Environments.RemoteUmbracoEnvironment.CompleteSessionAsync(Guid sessionId, CompleteInfos infos, CancellationToken token) at Umbraco.Deploy.Infrastructure.Work.WorkItems.DeployRestoreWorkItemBase.CloseSessionOn(IUmbracoEnvironment env, Boolean complete, Exception exception, Boolean silent, Nullable1 batchIndex, Nullable1 numberOfBatches) at Umbraco.Deploy.Infrastructure.Work.WorkItems.SourceDeployWorkItem.ExecuteForItems(IEnumerable1 items, Nullable1 batchIndex, Nullable1 numberOfBatches, CancellationToken token) at Umbraco.Deploy.Infrastructure.Work.WorkItems.SourceDeployWorkItem.ExecuteForItems(IEnumerable1 items, Nullable1 batchIndex, Nullable1 numberOfBatches, CancellationToken token) at Umbraco.Deploy.Infrastructure.Work.WorkItems.SourceDeployWorkItem.ExecuteForItems(IEnumerable`1 items, CancellationToken token) at Umbraco.Deploy.Infrastructure.Work.WorkItems.SourceDeployWorkItem.ExecuteAsync(IWorkContext context, CancellationToken token)

REMOTE: System.AggregateException: One or more errors occurred. (Wasn't able to get an UmbracoContext)

at Umbraco.Cms.Infrastructure.Scoping.Scope.TryFinally(Action[] actions) at Umbraco.Cms.Infrastructure.Scoping.Scope.RobustExit(Boolean completed, Boolean onException) at Umbraco.Cms.Infrastructure.Scoping.Scope.DisposeLastScope() at Umbraco.Cms.Infrastructure.Scoping.Scope.Dispose() at Umbraco.Deploy.Infrastructure.Core.AltScope.Dispose() at Umbraco.Deploy.Infrastructure.Work.WorkItems.SessionWorkItem.<>cDisplayClass24_0.b0() at Umbraco.Deploy.Infrastructure.Work.WorkTask.TryDo(Action action) at Umbraco.Deploy.Infrastructure.Work.WorkContext.TryDo(Action action) at Umbraco.Deploy.Infrastructure.Work.WorkItems.SessionWorkItem.Complete(Boolean success) at Umbraco.Deploy.Infrastructure.Work.WorkItems.SessionWorkItem.b23_0() --- End of stack trace from previous location --- at Umbraco.Deploy.Infrastructure.Work.WorkItems.SessionWorkItem.WaitIdle() at Umbraco.Deploy.Infrastructure.Environments.EnvironmentController.WaitCompleted(SessionActionModel model) at lambda_method7368(Closure, Object, Object[]) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.gAwaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) --> System.InvalidOperationException: Wasn't able to get an UmbracoContext

at Umbraco.Extensions.UmbracoContextAccessorExtensions.GetRequiredUmbracoContext(IUmbracoContextAccessor umbracoContextAccessor) at Umbraco.Cms.Infrastructure.DependencyInjection.UmbracoBuilderExtensions.<>c.b0_11(IServiceProvider factory) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitNoCache(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.b0(ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetServices[T](IServiceProvider provider) at Umbraco.Cms.Core.Events.NotificationHandlerWrapperImpl1.Handle[TNotification,TNotificationHandler](IEnumerable1 notifications, ServiceFactory serviceFactory, Action2 publish) at Umbraco.Cms.Core.Events.EventAggregator.PublishNotifications[TNotification,TNotificationHandler](IEnumerable1 notifications) at Umbraco.Cms.Core.Events.EventAggregator.Publish[TNotification,TNotificationHandler](IEnumerable1 notifications) at Umbraco.Deploy.Infrastructure.DeployScopedNotificationPublisher.PublishScopedNotifications(IList1 notifications) at Umbraco.Cms.Core.Events.ScopedNotificationPublisher`1.ScopeExit(Boolean completed) at Umbraco.Cms.Core.Scoping.CoreScope.HandleScopedNotifications() at Umbraco.Cms.Infrastructure.Scoping.Scope.TryFinally(Action[] actions)

dzilleb5 commented 9 months ago

We found what was causing our problems. We have a custom INotificationHandler<ContentSavingNotification> in our code. Which was injecting a IPublishedContentQuery in the constructor:

private readonly IPublishedContentQuery _publishedContentQuery; public ContentSavingNotificationHandler(IPublishedContentQuery publishedContentQuery) { _publishedContentQuery = publishedContentQuery; }

Removing the IPublishedContentQuery from our handler solved the issue.

Strange that this has never caused any issues before.