OctopusDeploy / Issues

| Public | Bug reports and known issues for Octopus Deploy and all related tools
https://octopus.com
161 stars 20 forks source link

Deleting a Runbook in a VCS project that has a variable scoped to causes variables page to error #8897

Open garrettdass opened 4 months ago

garrettdass commented 4 months ago

Severity

Low

Version

2024.2.9258

Latest Version

I could reproduce the problem in the latest build

What happened?

The variables.ocl doesn't update when deleting a Runbook. This leaves an unknown runbook scoped to a 'project variable' and breaks the page in the UI when rendering.

image

Reproduction

  1. Create a runbook in a VCS project
  2. Create a project variable and scope to the Runbook process
  3. Delete the Runbook
  4. See error when navigating to project variables page

Error and Stacktrace

* ProjectVariables.Variables[1].Scope["ProcessOwner"][0] has unknown slug "nameOfRunbook"

"Exception of type 'Octopus.Core.Serialization.Ocl.TinyTypeConversion.TinyTypeMappingException' was thrown."
Octopus.Core.Serialization.Ocl.TinyTypeConversion.TinyTypeMappingException: Exception of type 'Octopus.Core.Serialization.Ocl.TinyTypeConversion.TinyTypeMappingException' was thrown.
   at Octopus.Core.Serialization.Ocl.Transformation.Transforms.Decorators.IdToSlugOclTransformDecorator`1.ConvertSlugsToIds(T model, ProjectGitContext context) in ./source/Octopus.Core/Serialization/Ocl/Transformation/Transforms/Decorators/IdToSlugOclTransformDecorator.cs:line 37
   at Octopus.Core.Serialization.Ocl.Transformation.Transforms.Decorators.IdToSlugOclTransformDecorator`1.TransformFromOcl(String ocl, ProjectGitContext context, 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, ProjectGitContext context, CancellationToken cancellationToken) in ./source/Octopus.Core/Serialization/Ocl/OclHandler.cs:line 53
   at Octopus.Core.Git.Transactions.GitOclDocumentService.GetDocumentOrNull[T](String fileName, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitOclDocumentService.cs:line 49
   at Octopus.Core.Git.Transactions.GitOclDocumentService.GetDocument[T](String fileName, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitOclDocumentService.cs:line 61
   at Octopus.Core.Git.Transactions.GitDocumentTransaction.<>c__DisplayClass16_0`1.<<GetDocument>b__0>d.MoveNext() in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 73
--- End of stack trace from previous location ---
   at Octopus.Core.Git.Transactions.GitDocumentTransaction.MigrateBeforeExecute[T](Func`1 innerOperation, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 215
   at Octopus.Core.Git.Transactions.GitDocumentTransaction.GetDocument[T](String fileName, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 75
   at Octopus.Core.Persistence.Git.GitDocumentStore`2.Get(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/Git/GitDocumentStore.cs:line 88
   at Octopus.Core.Persistence.EntityTracking.NonTrackingDocumentStoreDecorator`2.Get(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/EntityTracking/NonTrackingDocumentStoreDecorator.cs:line 38
   at Octopus.Core.Persistence.DocumentStoreWithIdRouting`2.Get(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/DocumentStoreWithIdRouting.cs:line 112
   at Octopus.Core.Persistence.ReadOnlyDocumentStore`2.Get(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/ReadOnlyDocumentStore.cs:line 44
   at Octopus.Core.Features.Variables.GetProjectVariableSetRequestHandler.HandleInternal(VariableSetIdentifier variableSetId, CancellationToken cancellationToken) in ./source/Octopus.Core/Features/Variables/GetProjectVariableSetRequestHandler.cs:line 67
   at Octopus.Core.Features.Variables.GetProjectVariableSetRequestHandler.Handle(GetProjectVariableSetInGitRequest request, CancellationToken cancellationToken) in ./source/Octopus.Core/Features/Variables/GetProjectVariableSetRequestHandler.cs:line 60
   at Octopus.Core.Infrastructure.Mediator.AutofacMediator.Request[TRequest,TResponse](IRequest`2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/AutofacMediator.cs:line 37
   at Octopus.Core.Infrastructure.Mediator.Decorators.SystemComponentModelValidationDecorator.Request[TRequest,TResponse](IRequest`2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/SystemComponentModelValidationDecorator.cs:line 60
   at Octopus.Core.Infrastructure.Mediator.Decorators.FluentValidationsDecorator.Request[TRequest,TResponse](IRequest`2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/FluentValidationsDecorator.cs:line 78
   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.Variables.GetProjectVariableSetController.GetProjectVariableSetInGit(GetProjectVariableSetInGitRequest request, CancellationToken cancellationToken) in ./source/Octopus.Server/Web/Controllers/Variables/GetProjectVariableSetController.cs:line 32
   at lambda_method24150(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>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.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>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 50
   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 51
   at Octopus.Server.Web.Middleware.DynamicContentHeadersMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/DynamicContentHeadersMiddleware.cs:line 50
   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 59
   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 44
   at Octopus.Server.Web.Middleware.TelemetryMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/TelemetryMiddleware.cs:line 65
   at Octopus.Server.Web.Middleware.ErrorHandlingMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/ErrorHandlingMiddleware.cs:line 50
2024-07-01 15:54:37.2194   3704    164  INFO  "HTTP" "GET" to "localhost""/api/Spaces-1/projects/Projects-379/refs%2fheads%2fmain/variables" "completed" with 400 in 00:00:00.0350559 (35ms) by "garrett"
Octopus.Core.Serialization.Ocl.TinyTypeConversion.TinyTypeMappingException: Exception of type 'Octopus.Core.Serialization.Ocl.TinyTypeConversion.TinyTypeMappingException' was thrown.
   at Octopus.Core.Serialization.Ocl.Transformation.Transforms.Decorators.IdToSlugOclTransformDecorator`1.ConvertSlugsToIds(T model, ProjectGitContext context) in ./source/Octopus.Core/Serialization/Ocl/Transformation/Transforms/Decorators/IdToSlugOclTransformDecorator.cs:line 37
   at Octopus.Core.Serialization.Ocl.Transformation.Transforms.Decorators.IdToSlugOclTransformDecorator`1.TransformFromOcl(String ocl, ProjectGitContext context, 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, ProjectGitContext context, CancellationToken cancellationToken) in ./source/Octopus.Core/Serialization/Ocl/OclHandler.cs:line 53
   at Octopus.Core.Git.Transactions.GitOclDocumentService.GetDocumentOrNull[T](String fileName, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitOclDocumentService.cs:line 49
   at Octopus.Core.Git.Transactions.GitOclDocumentService.GetDocument[T](String fileName, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitOclDocumentService.cs:line 61
   at Octopus.Core.Git.Transactions.GitDocumentTransaction.<>c__DisplayClass16_0`1.<<GetDocument>b__0>d.MoveNext() in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 73
--- End of stack trace from previous location ---
   at Octopus.Core.Git.Transactions.GitDocumentTransaction.MigrateBeforeExecute[T](Func`1 innerOperation, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 215
   at Octopus.Core.Git.Transactions.GitDocumentTransaction.GetDocument[T](String fileName, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Transactions/GitDocumentTransaction.cs:line 75
   at Octopus.Core.Persistence.Git.GitDocumentStore`2.Get(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/Git/GitDocumentStore.cs:line 88
   at Octopus.Core.Persistence.EntityTracking.NonTrackingDocumentStoreDecorator`2.Get(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/EntityTracking/NonTrackingDocumentStoreDecorator.cs:line 38
   at Octopus.Core.Persistence.DocumentStoreWithIdRouting`2.Get(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/DocumentStoreWithIdRouting.cs:line 112
   at Octopus.Core.Persistence.ReadOnlyDocumentStore`2.Get(TKey id, CancellationToken cancellationToken) in ./source/Octopus.Core/Persistence/ReadOnlyDocumentStore.cs:line 44
   at Octopus.Core.Features.Variables.GetProjectVariableSetRequestHandler.HandleInternal(VariableSetIdentifier variableSetId, CancellationToken cancellationToken) in ./source/Octopus.Core/Features/Variables/GetProjectVariableSetRequestHandler.cs:line 67
   at Octopus.Core.Features.Variables.GetProjectVariableSetRequestHandler.Handle(GetProjectVariableSetInGitRequest request, CancellationToken cancellationToken) in ./source/Octopus.Core/Features/Variables/GetProjectVariableSetRequestHandler.cs:line 60
   at Octopus.Core.Infrastructure.Mediator.AutofacMediator.Request[TRequest,TResponse](IRequest`2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/AutofacMediator.cs:line 37
   at Octopus.Core.Infrastructure.Mediator.Decorators.SystemComponentModelValidationDecorator.Request[TRequest,TResponse](IRequest`2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/SystemComponentModelValidationDecorator.cs:line 60
   at Octopus.Core.Infrastructure.Mediator.Decorators.FluentValidationsDecorator.Request[TRequest,TResponse](IRequest`2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/FluentValidationsDecorator.cs:line 78
   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.Variables.GetProjectVariableSetController.GetProjectVariableSetInGit(GetProjectVariableSetInGitRequest request, CancellationToken cancellationToken) in ./source/Octopus.Server/Web/Controllers/Variables/GetProjectVariableSetController.cs:line 32
   at lambda_method24150(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>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.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>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 50
   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 51
   at Octopus.Server.Web.Middleware.DynamicContentHeadersMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/DynamicContentHeadersMiddleware.cs:line 50
   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 59
   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 44
   at Octopus.Server.Web.Middleware.TelemetryMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/TelemetryMiddleware.cs:line 65
   at Octopus.Server.Web.Middleware.ErrorHandlingMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/ErrorHandlingMiddleware.cs:line 50

More Information

No response

Workaround

Remove scope from the variable(s) or the variables themselves from the variables.ocl on the Git side.

felixi-octopus commented 2 months ago

This issue also occurs when you delete an environment or channel that a variable is scoped to