NullReferenceException when creating a release from GitHub action

Hello,

I’m in the process of migrating to using GitHub actions to create releases in Octopus and I’ve run into an issue where Octopus Server throws a NullReference exception when I try to do so, and I can’t work out why. I have upgraded my server to latest version (Version 2022.4 (Build 8394))

My GitHub action looks like this:

    - name: Deploy release in Octopus Deploy 🐙
      uses: OctopusDeploy/deploy-release-action@v3
      env:
        OCTOPUS_URL: ${{ secrets.OCTOPUSSERVERURL }}
        OCTOPUS_API_KEY: ${{ secrets.OCTOPUSSERVERAPIKEY }}
        OCTOPUS_SPACE: ${{ secrets.OCTOPUSSERVER_SPACE }}
      with:
        project: 'MyProjectName'
        release_number: '${{env.package_version}}'
        environments: |
          dev

The log on GitHub seems to be resolving all the env variables fine, and the API key works fine for pushing the packages

2023-02-05T19:45:21.1521888Z ##[group]Run OctopusDeploy/deploy-release-action@v3
2023-02-05T19:45:21.1522167Z with:
2023-02-05T19:45:21.1522361Z   project: MyProjectName
2023-02-05T19:45:21.1522591Z   release_number: 3.10.1
2023-02-05T19:45:21.1522825Z   environments: dev

2023-02-05T19:45:21.1523311Z   use_guided_failure: false
2023-02-05T19:45:21.1523519Z env:
2023-02-05T19:45:21.1523719Z   DOTNET_VERSION: 7.0.x
2023-02-05T19:45:21.1523964Z   DOTNET_ROOT: /usr/share/dotnet
2023-02-05T19:45:21.1524191Z   package_version: 3.10.1
2023-02-05T19:45:21.1524529Z   OCTOPUS_URL: ***
2023-02-05T19:45:21.1524836Z   OCTOPUS_API_KEY: ***
2023-02-05T19:45:21.1525061Z   OCTOPUS_SPACE: ***
2023-02-05T19:45:21.1525267Z ##[endgroup]
2023-02-05T19:45:21.9378962Z 🐙 Deploying a release in Octopus Deploy...
2023-02-05T19:45:23.6361532Z ##[error]Error: Object reference not set to an instance of an object.

And the log on the server looks like the following. Any ideas what’s not getting set correctly?

Unhandled error on request: “Object reference not set to an instance of an object.” System.NullReferenceException: Object reference not set to an instance of an object.
at Octopus.Server.Web.Handlers.GetTemplateRequestHandler.Handle(GetTemplateRequest request, CancellationToken cancellationToken) in ./source/Octopus.Server/Web/Handlers/GetTemplateRequestHandler.cs:line 89
at Octopus.Core.Infrastructure.Mediator.AutofacMediator.Request[TRequest,TResponse](IRequest2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/AutofacMediator.cs:line 38 at Octopus.Core.Infrastructure.Mediator.Decorators.SystemComponentModelValidationDecorator.Request[TRequest,TResponse](IRequest2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/SystemComponentModelValidationDecorator.cs:line 44
at Octopus.Core.Infrastructure.Mediator.Decorators.FluentValidationsDecorator.Request[TRequest,TResponse](IRequest2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/FluentValidationsDecorator.cs:line 66 at Octopus.Core.Infrastructure.Mediator.Decorators.MessageBusSiphoningDecorator.Request[TRequest,TResponse](IRequest2 request, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/MessageBusSiphoningDecorator.cs:line 38
at Octopus.Server.Extensibility.Projects.CreateExecutions.UntenantedDeploymentFactory.DeployRelease(CreateDeploymentUntenantedCommandV1 untenantedCommandV1, ProjectResource project, ReleaseId releaseId, CancellationToken cancellationToken) in ./source/Octopus.Server.Extensibility.Projects.CreateExecutions/UntenantedDeploymentFactory.cs:line 31
at Octopus.Server.Extensibility.Projects.CreateExecutions.CreateDeploymentUntenantedCommandV1Handler.DeployRelease(CreateDeploymentUntenantedCommandV1 untenantedCommandV1, ProjectResource project, ReleaseId releaseId, CancellationToken cancellationToken) in ./source/Octopus.Server.Extensibility.Projects.CreateExecutions/CreateDeploymentUntenantedCommandV1Handler.cs:line 54
at Octopus.Server.Extensibility.Projects.CreateExecutions.CreateDeploymentUntenantedCommandV1Handler.Handle(CreateDeploymentUntenantedCommandV1 createDeploymentUntenantedCommandV1, CancellationToken cancellationToken) in ./source/Octopus.Server.Extensibility.Projects.CreateExecutions/CreateDeploymentUntenantedCommandV1Handler.cs:line 47
at Octopus.Core.Infrastructure.Mediator.AutofacMediator.Do[TCommand,TResponse](ICommand2 command, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/AutofacMediator.cs:line 29 at Octopus.Core.Infrastructure.Mediator.Decorators.SystemComponentModelValidationDecorator.Do[TCommand,TResponse](ICommand2 command, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/SystemComponentModelValidationDecorator.cs:line 32
at Octopus.Core.Infrastructure.Mediator.Decorators.FluentValidationsDecorator.Do[TCommand,TResponse](ICommand2 command, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/FluentValidationsDecorator.cs:line 45 at Octopus.Core.Infrastructure.Mediator.Decorators.MessageBusSiphoningDecorator.Do[TCommand,TResponse](ICommand2 command, CancellationToken cancellationToken) in ./source/Octopus.Core/Infrastructure/Mediator/Decorators/MessageBusSiphoningDecorator.cs:line 33
at Octopus.Server.Extensibility.Projects.CreateExecutions.CreateDeploymentUntenantedController.Create(CreateDeploymentUntenantedCommandV1 untenantedCommandV1, CancellationToken cancellationToken) in ./source/Octopus.Server.Extensibility.Projects.CreateExecutions/CreateDeploymentUntenantedController.cs:line 27
at lambda_method12995(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.Infrastructure.Authentication.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult) in ./source/Octopus.Server/Web/Infrastructure/Authentication/AuthorizationMiddlewareResultHandler.cs:line 52
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 47
at Octopus.Server.Web.UnitOfWorkMiddleware.InvokeAsync(HttpContext httpContext, IUnitOfWork unitOfWork) in ./source/Octopus.Server/Web/UnitOfWorkMiddleware.cs:line 47
at Octopus.Server.Web.Middleware.OctopusClientOldVersionWarningMiddleware.InvokeAsync(HttpContext context, IAutomationContext automationContext) in ./source/Octopus.Server/Web/Middleware/OctopusClientOldVersionWarningMiddleware.cs:line 53
at Octopus.Server.Web.Middleware.DynamicContentHeadersMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/DynamicContentHeadersMiddleware.cs:line 49
at Octopus.Server.Web.Middleware.MaintenanceModeMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/MaintenanceModeMiddleware.cs:line 61
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 57
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 42
at Octopus.Server.Web.Middleware.TelemetryMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/TelemetryMiddleware.cs:line 75
at Octopus.Server.Web.Middleware.ErrorHandlingMiddleware.InvokeAsync(HttpContext context) in ./source/Octopus.Server/Web/Middleware/ErrorHandlingMiddleware.cs:line 115

Hi @Iain_Brown,

Thanks for getting in touch! I’m sorry to see you’re hitting this roadblock. Unfortunately I can’t tell conclusively what’s causing this error to be thrown at this stage, but I have a few questions to hopefully narrow down what might be going on.

Is this a tenant-required project? If so, you can use the deploy-release-tenanted-action to pass in tenants/tenant tags into the command.

Does this project have required prompted variables? The values to these variables need to be supplied when creating the deployment via:

      variables: |
        Foo: Bar
        Fizz: Buzz

Is this a version controlled project?

Lastly, would you be willing to send a copy of the build log for us to look into? If this proves to be needed, you can upload it to this secure link. :slight_smile:

I hope this helps for the time being. I look forward to getting to the bottom of this one!

Best regards,

Kenny

Hey Kenneth,

Thanks for looking into this. I managed to work it out in the end, I was using the wrong action, I should have been using the Create Release action, not the Deploy Release action. So it was an error at my end, but it’d be nice if the server returned a better error if this happens, it’s fairly easy to get terms confused.

Cheers

Iain

1 Like

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