OctopusDeploy / Issues

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

Error viewing Projects after upgrading to 2023.2.X - "Object Reference not set to an instance of an object" - ConnectivityPolicy is NULL #8200

Closed FinnianDempsey closed 1 year ago

FinnianDempsey commented 1 year ago

Severity

Blocking Issue

Version

2023.2.2172

Latest Version

I could reproduce the problem in the latest build

What happened?

After upgrading to 2023.2.X, users are unable to view certain projects causing deployments to fail which rely on them and are seeing the Object Reference not set to an instance of an object error.

Reproduction

Set Deployment Process ConnectivityPolicy to NULL Upgrade and see issue

Error and Stacktrace

"HTTP" "GET" to "octo.domain.local""/api/Spaces-1/projects" "completed" with 500 in 00:00:03.2736683 (3273ms) by "finnocto"
System.NullReferenceException: Object reference not set to an instance of an object.
   at Octopus.Server.Web.Mapping.Mappings.DeploymentSettingsMappings.MapFromDeploymentSettingsToDeploymentSettingsResource.MapToNewDeploymentConnectivityPolicy(DeploymentSettings source) in ./source/Octopus.Server/Web/Mapping/Mappings/DeploymentSettingsMappings/MapFromDeploymentSettingsToDeploymentSettingsResource.cs:line 93
   at Octopus.Server.Web.Mapping.Mappings.DeploymentSettingsMappings.MapFromDeploymentSettingsToDeploymentSettingsResource.Map(DeploymentSettings source, CancellationToken cancellationToken) in ./source/Octopus.Server/Web/Mapping/Mappings/DeploymentSettingsMappings/MapFromDeploymentSettingsToDeploymentSettingsResource.cs:line 56
   at Octopus.Core.Features.Projects.GetProjectsRequestHandler.PolyfillDeploymentSettings(IEnumerable`1 projectResources, CancellationToken cancellationToken) in ./source/Octopus.Core/Features/Projects/GetProjectsRequestHandler.cs:line 85
   at Octopus.Core.Features.Projects.GetProjectsRequestHandler.Handle(GetProjectsRequest request, CancellationToken cancellationToken) in ./source/Octopus.Core/Features/Projects/GetProjectsRequestHandler.cs:line 65
   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.Projects.GetProjectsController.GetProjects(GetProjectsRequest request, CancellationToken cancellationToken) in ./source/Octopus.Server/Web/Controllers/Projects/GetProjectsController.cs:line 27
   at lambda_method21658(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()
--- End of stack trace from previous location ---

More Information

No response

Workaround

The following queries can be ran against the DB to confirm and resolve this issue. Please make sure to take a backup of your DB and Master Key and consult with your DBA before running any queries.

To find Projects with NULL ConnectivityPolicy:

SELECT Id, JSON_QUERY([JSON], '$.ConnectivityPolicy')
FROM [dbo].[DeploymentSettings]
WHERE JSON_QUERY([JSON], '$.ConnectivityPolicy') is null

To modify NULL to the default ConnectivityPolicy:

BEGIN TRAN

UPDATE dbo.DeploymentSettings
SET JSON = JSON_MODIFY([JSON],'$.ConnectivityPolicy',JSON_QUERY('{"SkipMachineBehavior":"None","TargetRoles":[],"AllowDeploymentsToNoTargets":true,"ExcludeUnhealthyTargets":false}'))
WHERE JSON_QUERY([JSON], '$.ConnectivityPolicy') IS NULL;

ROLLBACK TRAN 

(Change ROLLBACK to COMMIT to action the change)

Please reach out to support@octopus.com with any questions or issues!

Clare-Octopus commented 1 year ago

You may also be experiencing this issue if you are running scripts or accessing an Octopus function via the UI that requires access to api/Spaces-1/projects(such as connecting a project to a tenant in the UI or using the REST API to call a project using that API endpoint). If you do see this the error you will get is:

There was an error making a Get call to the https://<octopusinstanceurl>/api/Spaces-1/projects. Please check that for more information.

System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

If you get that error and are unsure if this is related to this GitHub issue please reach out to support at support@octopus.com and we would be happy to help.

If you run the 'find Projects with NULL ConnectivityPolicy' DB query in the workaround in this issue and you get results back from that query then you will be affected by this GitHub issue.

Kind Regards, Clare

donnybell commented 1 year ago

Another affected customer [Internal Link]

susanpann commented 1 year ago

Shane's patch merged into master

octoreleasebot commented 1 year ago

Release Note: Fixed a regression that prevented some projects from loading

Octobob commented 1 year ago

:tada: The fix for this issue has been released in:

Release stream Release
2023.2 2023.2.12329
2023.3 2023.3.3672
2023.4+ all releases