Skip to content

panic: runtime error: invalid memory address or nil pointer dereference #4440

Closed

Description

Output from azd version
Run azd version and copy and paste the output here:

azd version 1.10.2 (commit 84ea22048b9a1c167bc4ae2095cc7f91798ef11e)

Describe the bug
AZD is crashing when I am trying to deploy a .NET Aspire 8.2.1 project. Here is the error I get:

PS C:\Code\postgresbug\PostgresBug.AppHost> azd up

Packaging services (azd package)


Provisioning Azure resources (azd provision)
Provisioning Azure resources can take some time.

Subscription: midenn (9ab12ed0-87cd-4402-9e18-9b67142c6c30)
Location: East US 2

  (-) Skipped: Didn't find new changes.

Deploying services (azd deploy)

  |=======| Deploying service apiservice (Updating container app)panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x30 pc=0xc6619e]

goroutine 1 [running]:
github.com/azure/azure-dev/cli/azd/pkg/containerapps.(*containerAppService).persistSettings(0xc0001f77d0, {0x155c780, 0xc0006376e0}, {0xc0001e6720, 0x24}, {0xc000512170, 0xf}, {0xc000496d80, 0xa}, 0xc000608ff0, ...)
        github.com/azure/azure-dev/cli/azd/pkg/containerapps/container_app.go:154 +0x23e
github.com/azure/azure-dev/cli/azd/pkg/containerapps.(*containerAppService).DeployYaml(0xc0001f77d0, {0x155c780, 0xc0006376e0}, {0xc0001e6720, 0x24}, {0xc000512170, 0xf}, {0xc000496d80, 0xa}, {0xc000689000, ...}, ...)
        github.com/azure/azure-dev/cli/azd/pkg/containerapps/container_app.go:187 +0x15c
github.com/azure/azure-dev/cli/azd/pkg/project.(*dotnetContainerAppTarget).Deploy(0xc000492a20, {0x155c780, 0xc0006376e0}, 0xc00063e488, 0xc000399590, 0xc000055540, 0xc00010c860)       
        github.com/azure/azure-dev/cli/azd/pkg/project/service_target_dotnet_containerapp.go:401 +0x19a9
github.com/azure/azure-dev/cli/azd/pkg/project.(*serviceManager).Deploy.func1()
        github.com/azure/azure-dev/cli/azd/pkg/project/service_manager.go:481 +0x34
github.com/azure/azure-dev/cli/azd/pkg/project.runCommand[...].func1()
        github.com/azure/azure-dev/cli/azd/pkg/project/service_manager.go:648 +0x22
github.com/azure/azure-dev/cli/azd/pkg/ext.(*EventDispatcher[...]).Invoke(0x1569ea0, {0x155c780, 0xc0006376e0}, {0x13580c0, 0x6}, {0xc0004be700, 0xc00063e488?, 0x0?}, 0xc000577b48)     
        github.com/azure/azure-dev/cli/azd/pkg/ext/event_dispatcher.go:113 +0x25e
github.com/azure/azure-dev/cli/azd/pkg/project.runCommand[...]({0x155c780?, 0xc0006376e0?}, {0x13580c0?, 0x24?}, 0x0?, 0xc000577be0?)
        github.com/azure/azure-dev/cli/azd/pkg/project/service_manager.go:647 +0x87
github.com/azure/azure-dev/cli/azd/pkg/project.(*serviceManager).Deploy(0xc0003119c0, {0x155c780, 0xc0006376e0}, 0xc00063e488, 0xc000399590, 0xc00010c860)
        github.com/azure/azure-dev/cli/azd/pkg/project/service_manager.go:476 +0x5ef
github.com/azure/azure-dev/cli/azd/internal/cmd.(*DeployAction).Run.func5(0x0?)
        github.com/azure/azure-dev/cli/azd/internal/cmd/deploy.go:282 +0x37
github.com/azure/azure-dev/cli/azd/pkg/async.RunWithProgress[...](0xc0003996b0, 0xc000577e88)
        github.com/azure/azure-dev/cli/azd/pkg/async/progress.go:46 +0xfe
github.com/azure/azure-dev/cli/azd/internal/cmd.(*DeployAction).Run(0xc0000f02d0, {0x155c780, 0xc0006376e0})
        github.com/azure/azure-dev/cli/azd/internal/cmd/deploy.go:276 +0xb48
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction.func1({0x155c780, 0xc0006376e0})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:126 +0x434
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*HooksMiddleware).registerCommandHooks(0xc000480640?, {0x155c780, 0xc0006376e0}, 0xc000637a10?, 0xc0004be700?, 0xc000310c80)
        github.com/azure/azure-dev/cli/azd/cmd/middleware/hooks.go:81 +0x39b
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*HooksMiddleware).Run(0xc000480640, {0x155c780, 0xc0006376e0}, 0xc000310c80)
        github.com/azure/azure-dev/cli/azd/cmd/middleware/hooks.go:66 +0x1be
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction.func1({0x155c780, 0xc0006376e0})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:109 +0x2b8
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*TelemetryMiddleware).Run(0xc0009f2680, {0x155c780, 0xc000636750}, 0xc000310c80)
        github.com/azure/azure-dev/cli/azd/cmd/middleware/telemetry.go:78 +0x8ee
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction.func1({0x155c780, 0xc000636750})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:109 +0x2b8
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*UxMiddleware).Run(0xc000646180, {0x155c780, 0xc000636750}, 0xc000310c80)
        github.com/azure/azure-dev/cli/azd/cmd/middleware/ux.go:29 +0x375
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction.func1({0x155c780, 0xc000636750})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:109 +0x2b8
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*DebugMiddleware).Run(0xc000646150, {0x155c780, 0xc000636750}, 0xc000310c80)
        github.com/azure/azure-dev/cli/azd/cmd/middleware/debug.go:34 +0x3a8
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction.func1({0x155c780, 0xc000636750})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:109 +0x2b8
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction(0xc000081240, {0x155c780, 0xc000636750}, 0xc000209560, {0xc0003e4528, 0x11})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:130 +0x137
github.com/azure/azure-dev/cli/azd/cmd.(*CobraBuilder).configureActionResolver.func1(0xc0003aa2c8, {0xc0009f2510, 0x0, 0x1})
        github.com/azure/azure-dev/cli/azd/cmd/cobra_builder.go:130 +0x386
github.com/spf13/cobra.(*Command).execute(0xc0003aa2c8, {0xc0009f2500, 0x1, 0x1})
        github.com/spf13/cobra@v1.3.0/command.go:856 +0x68a
github.com/spf13/cobra.(*Command).ExecuteC(0xc00037e848)
        github.com/spf13/cobra@v1.3.0/command.go:974 +0x38d
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.3.0/command.go:902
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        github.com/spf13/cobra@v1.3.0/command.go:895
github.com/azure/azure-dev/cli/azd/cmd.(*workflowCmdAdapter).ExecuteContext(0xc0006020d0, {0x155c780, 0xc00026c810})
        github.com/azure/azure-dev/cli/azd/cmd/container.go:808 +0xa5
github.com/azure/azure-dev/cli/azd/pkg/workflow.(*Runner).Run(0xc0000127c0, {0x155c780, 0xc00026c810}, 0x2?)
        github.com/azure/azure-dev/cli/azd/pkg/workflow/runner.go:38 +0xce
github.com/azure/azure-dev/cli/azd/cmd.(*upAction).Run(0xc000209560, {0x155c780, 0xc00026c810})
        github.com/azure/azure-dev/cli/azd/cmd/up.go:133 +0x2e5
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction.func1({0x155c780, 0xc00026c810})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:126 +0x434
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*HooksMiddleware).registerCommandHooks(0xc00037dcc0?, {0x155c780, 0xc00026c810}, 0xc00026d7a0?, 0xc00022fa00?, 0xc000310c40)
        github.com/azure/azure-dev/cli/azd/cmd/middleware/hooks.go:81 +0x39b
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*HooksMiddleware).Run(0xc00037dcc0, {0x155c780, 0xc00026c810}, 0xc000310c40)
        github.com/azure/azure-dev/cli/azd/cmd/middleware/hooks.go:66 +0x1be
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction.func1({0x155c780, 0xc00026c810})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:109 +0x2b8
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*TelemetryMiddleware).Run(0xc00024d7c0, {0x155c780, 0xc000221740}, 0xc000310c40)
        github.com/azure/azure-dev/cli/azd/cmd/middleware/telemetry.go:78 +0x8ee
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction.func1({0x155c780, 0xc000221740})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:109 +0x2b8
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*UxMiddleware).Run(0xc0000086d8, {0x155c780, 0xc000221740}, 0xc000310c40)
        github.com/azure/azure-dev/cli/azd/cmd/middleware/ux.go:32 +0xa9
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction.func1({0x155c780, 0xc000221740})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:109 +0x2b8
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*DebugMiddleware).Run(0xc0000086a8, {0x155c780, 0xc000221740}, 0xc000310c40)
        github.com/azure/azure-dev/cli/azd/cmd/middleware/debug.go:48 +0x382
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction.func1({0x155c780, 0xc000221740})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:109 +0x2b8
github.com/azure/azure-dev/cli/azd/cmd/middleware.(*MiddlewareRunner).RunAction(0xc00024a580, {0x155c780, 0xc000221740}, 0xc000209440, {0xc00024e610, 0xd})
        github.com/azure/azure-dev/cli/azd/cmd/middleware/middleware.go:130 +0x137
github.com/azure/azure-dev/cli/azd/cmd.(*CobraBuilder).configureActionResolver.func1(0xc0003aa588, {0x1e02560, 0x0, 0x0})
        github.com/azure/azure-dev/cli/azd/cmd/cobra_builder.go:130 +0x386
github.com/spf13/cobra.(*Command).execute(0xc0003aa588, {0x1e02560, 0x0, 0x0})
        github.com/spf13/cobra@v1.3.0/command.go:856 +0x68a
github.com/spf13/cobra.(*Command).ExecuteC(0xc00037e848)
        github.com/spf13/cobra@v1.3.0/command.go:974 +0x38d
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.3.0/command.go:902
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        github.com/spf13/cobra@v1.3.0/command.go:895
main.main()
        D:/a/_work/1/s/cli/azd/main.go:65 +0x24b

To Reproduce

  1. I downloaded and installed .NET Aspire 9.0 RC1 project templates.
  2. I created a .NET Aspire 8.2.1 starter: dotnet install -o . --name PostgresBug
  3. Added Aspire.Hosting.Azure.PostgreSql package to the app host.
  4. Wrote the following code in app host:
var builder = DistributedApplication.CreateBuilder(args);

var db = builder.AddPostgres("pg")
                .PublishAsAzurePostgresFlexibleServer()
                .AddDatabase("db");

var apiService = builder.AddProject<Projects.PostgresBug_ApiService>("apiservice")
                        .WithReference(db);

builder.AddProject<Projects.PostgresBug_Web>("webfrontend")
    .WithExternalHttpEndpoints()
    .WithReference(apiService);

builder.Build().Run();

Then did azd init and azd up. Then the error above was displayed (error is from the second deployment because I tried it again just in case it was a solar flare or something.

Expected behavior
A clear and concise description of what you expected to happen.

Should deploy without errors.

Environment
Information on your environment:
* Language name and version:
* IDE and version : [e.g. Visual Studio 16.3]

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions