EntityNotFoundException when transferring Project between Servers

I have a project on Server A which is has been committed to GitHub. I have installed a fresh instance of Octopus on Server B and want to transfer the project to that server. When I point the new instance to the GitHub repo, it fails to rehydrate with EntityNotFoundException.
I have created what I believe are the Library and Infra dependencies: Environments, Variable Sets, Step Templates, Certificates etc.
Neither the Octopus GUI nor the Octopus server logs indicate the issue. Octopus version is 2023.1b9767
I’m assuming there’s some sort of unmet dependency of slug/key difference. Any way to get more information on what’s going on?

Hi @mark-qds,

Thank you for contacting Octopus Support. I’m sorry you are running into issues when transferring your git-enabled Project.

Are you able to share the full error you are seeing on your end on Server B?

Let me know at your earliest convenience.

Best Regards,
Donny Bell

In the Octopus Server Web UI, when I click on “Process” it gives the error: “Resource is not found or it doesn’t exist in the current space context. Please contact your administrator for more information.”

Full stack track from OctopusServer.txt log:

2023-06-01 09:04:50.4500 4440 160 INFO “Exception of type ‘Octopus.Core.Model.Exceptions.EntityNotFoundException’ was thrown.”
Octopus.Core.Model.Exceptions.EntityNotFoundException: Exception of type ‘Octopus.Core.Model.Exceptions.EntityNotFoundException’ was thrown.
at Octopus.Core.Serialization.Ocl.Transformation.Transforms.DeploymentProcessOclTransform.HydrateAction(DeploymentAction action, IEnumerable1 actionTemplateLookups) in ./source/Octopus.Core/Serialization/Ocl/Transformation/Transforms/DeploymentProcessOclTransform.cs:line 93 at Octopus.Core.Serialization.Ocl.Transformation.Transforms.DeploymentProcessOclTransform.TransformFromOcl(String ocl, CancellationToken cancellationToken) in ./source/Octopus.Core/Serialization/Ocl/Transformation/Transforms/DeploymentProcessOclTransform.cs:line 74 at Octopus.Core.Serialization.Ocl.Transformation.Transforms.Decorators.IdToSlugOclTransformDecorator1.TransformFromOcl(String ocl, CancellationToken cancellationToken) in ./source/Octopus.Core/Serialization/Ocl/Transformation/Transforms/Decorators/IdToSlugOclTransformDecorator.cs:line 33
at Octopus.Core.Serialization.Ocl.OclHandler.FromOcl[T](String ocl, CancellationToken cancellationToken) in ./source/Octopus.Core/Serialization/Ocl/OclHandler.cs:line 55
at Octopus.Core.Git.Transactions.GitOclDocumentService.GetDocumentOrNull[T](String fileName, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitOclDocumentService.cs:line 45
at Octopus.Core.Git.Transactions.GitDocumentTransaction.<>c__DisplayClass15_01.<<GetDocumentOrNull>b__0>d.MoveNext() in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 66 --- End of stack trace from previous location --- at Octopus.Core.Git.Transactions.GitDocumentTransaction.MigrateBeforeExecute[T](Func1 innerOperation, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 214
at Octopus.Core.Git.Transactions.GitDocumentTransaction.GetDocumentOrNull[T](String fileName, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 65
at Octopus.Core.Persistence.Git.GitDocumentStore2.GetOrNull(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/Git/GitDocumentStore.cs:line 111 at Octopus.Core.Persistence.Database.ProjectPathDecorators.ProjectPathDocumentStoreDecorator2.GetOrNull(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/Database/ProjectPathDecorators/ProjectPathDocumentStoreDecorator.cs:line 39
at Octopus.Core.Persistence.EntityTracking.NonTrackingDocumentStoreDecorator2.GetOrNull(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/EntityTracking/NonTrackingDocumentStoreDecorator.cs:line 40 at Octopus.Core.Persistence.ReadOnlyDocumentStore2.GetOrNull(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/ReadOnlyDocumentStore.cs:line 46
at Octopus.Core.Features.DeploymentProcesses.CurrentDeploymentProcessDocumentStoreExtensionMethods.GetOrNullByProject(IReadOnlyDocumentStore2 documentStore, Project project, CancellationToken cancellationToken) in ./source/Octopus.Core/Features/DeploymentProcesses/CurrentDeploymentProcessDocumentStoreExtensionMethods.cs:line 15 at Octopus.Core.Features.Projects.GetProjectSummaryRequestHandler.Handle(GetProjectSummaryRequest request, CancellationToken cancellationToken) in ./source/Octopus.Core/Features/Projects/GetProjectSummaryRequestHandler.cs:line 36 at Octopus.Core.Infrastructure.Mediator.AutofacMediator.Request[TRequest,TResponse](IRequest2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/AutofacMediator.cs:line 35
at Octopus.Core.Infrastructure.Mediator.Decorators.SystemComponentModelValidationDecorator.Request[TRequest,TResponse](IRequest2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/SystemComponentModelValidationDecorator.cs:line 48 at Octopus.Core.Infrastructure.Mediator.Decorators.FluentValidationsDecorator.Request[TRequest,TResponse](IRequest2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/FluentValidationsDecorator.cs:line 62
at Octopus.Core.Infrastructure.Mediator.Decorators.MessageBusSiphoningDecorator.Request[TRequest,TResponse](IRequest`2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/MessageBusSiphoningDecorator.cs:line 37
at Octopus.Server.Web.Controllers.Projects.GetProjectSummaryController.GetProjectSummary_Legacy(GetProjectSummaryRequest request, CancellationToken cancellationToken) in ./source/Octopus.Server/Web/Controllers/Projects/GetProjectSummaryController.cs:line 23
at lambda_method20186(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(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.g__Awaited|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|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Octopus.Server.Web.Middleware.BoundaryTrailerRewriteMiddleware.Invoke(HttpContext context, IAutomationContext automationContext) in ./source/Octopus.Server/Web/Middleware/BoundaryTrailerRewriteMiddleware.cs:line 44
at Octopus.Server.Web.Infrastructure.Authentication.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult) in ./source/Octopus.Server/Web/Infrastructure/Authentication/AuthorizationMiddlewareResultHandler.cs:line 48
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Octopus.Server.Web.UnitOfWorkMiddleware.InvokeAsync(HttpContext httpContext, IUnitOfWork unitOfWork) in ./source/Octopus.Server/Web/UnitOfWorkMiddleware.cs:line 46
at Octopus.Server.Web.UnitOfWorkMiddleware.InvokeAsync(HttpContext httpContext, IUnitOfWork unitOfWork) in ./source/Octopus.Server/Web/UnitOfWorkMiddleware.cs:line 46
at Octopus.Server.Web.Middleware.OctopusClientOldVersionWarningMiddleware.InvokeAsync(HttpContext context, IAutomationContext automationContext) in ./source/Octopus.Server/Web/Middleware/OctopusClientOldVersionWarningMiddleware.cs:line 52
at Octopus.Server.Web.Middleware.DynamicContentHeadersMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/DynamicContentHeadersMiddleware.cs:line 48
at Octopus.Server.Web.Middleware.MaintenanceModeMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/MaintenanceModeMiddleware.cs:line 59
at Octopus.Server.Web.Middleware.OctopusAuthenticationMiddleware.InvokeAsync(HttpContext context, IUserAuthenticator userAuthenticator, IAuthCookieService authCookieService, IWebAuthCache authCache, ILogger logger) in ./source/Octopus.Server/Web/Middleware/OctopusAuthenticationMiddleware.cs:line 58
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Octopus.Server.Web.Middleware.LegacyRequestLoggerMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/LegacyRequestLoggerMiddleware.cs:line 41
at Octopus.Server.Web.Middleware.TelemetryMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/TelemetryMiddleware.cs:line 76
at Octopus.Server.Web.Middleware.ErrorHandlingMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/ErrorHandlingMiddleware.cs:line 117

@donny.bell I did some further investigations by manually removing steps from the deployment_process.ocl file. I traced the issue down to the Step Templates. Since custom Step Templates aren’t stored with the source control, I exported the Step Template from Server A and imported it into Server B. Now looking at the relevant deployment_process.ocl, there’s an entry:
Octopus.Action.Template.Id = “ActionTemplates-144”
When exporting the Step Template, it doesn’t export the ID “ActionTemplates-144”.
So I’m assuming on Server B, when I imported the Step Template, it’s used a different ID, and when the deployment_process.ocl tries to import this step it fails because it can’t find ActionTemplates-144. There doesn’t seem to be a way to set the slug/ID of the action template or for the deployment_process.ocl file to use a well known name when referencing Step Templates.
I would appreciate a change in Octopus Server to allow this

Hi @mark-qds,

Just stepping in for Donny while he’s offline, cheers for that extra info!

Unfortunately it looks like this might fall under the un-supported Config as Code scenarios, where we call out that pointing 2 instances to the same repository is likely to cause trouble over time, especially with Step Templates. As you’ve found the second instance will need to have matching ActionTemplateId’s in order to use the reference to a specific ID from the first instance: Unsupported Configuration as Code Scenarios - Octopus Deploy

For moving project across Octopus Instance’s, we recommend using our Project Import/Export tool as that will bundle the Step Templates etc in the Export:
https://octopus.com/docs/projects/export-import#what-is-imported

I hope that helps but feel free to reach out with any questions or issues at all!

Best Regards,

Unfortunately, it looks like we can’t export version controlled projects, and you can’t de-activate version control once it is turned on. It’s very unfortunate that this is not supported within Octopus. In summary, I have two requests from this issue:

  1. Provide more informative errors when transferring version controlled projects
  2. Provide support for version controlled projects with Step Templates

Hi @mark-qds,

Sorry for giving the wrong suggestion, I hadn’t realised version controlled projects aren’t able to be exported!

I’ve raised this internally as I agree there is definitely an issue here and the error message could better indicate what’s going wrong.

I’ll keep you posted with any updates or issues created, or if I’m able to figure out a workaround in the meantime.

Best Regards,

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.