{"record":{"id":"39e6edf4dbbaaeee","repo":"microsoft/aspire","slug":"dashboard-resource-is-not-initialized","errorCode":null,"errorMessage":"Dashboard resource is not initialized","messagePattern":"Dashboard resource is not initialized","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Docker/DockerComposeEnvironmentExtensions.cs","lineNumber":199,"sourceCode":"    }\n\n    /// <summary>\n    /// Configures the dashboard properties for this Docker Compose environment.\n    /// </summary>\n    /// <param name=\"builder\">The Docker Compose environment resource builder.</param>\n    /// <param name=\"configure\">A method that can be used for customizing the dashboard service.</param>\n    /// <returns>A reference to the <see cref=\"IResourceBuilder{T}\"/>.</returns>\n    /// <ats-returns>The resource builder.</ats-returns>\n    [AspireExport(\"configureDashboard\", MethodName = \"configureDashboard\", RunSyncOnBackgroundThread = true)]\n    public static IResourceBuilder<DockerComposeEnvironmentResource> WithDashboard(this IResourceBuilder<DockerComposeEnvironmentResource> builder, Action<IResourceBuilder<DockerComposeAspireDashboardResource>> configure)\n    {\n        ArgumentNullException.ThrowIfNull(builder);\n        ArgumentNullException.ThrowIfNull(configure);\n\n        // Ensure the dashboard resource is initialized\n        builder.Resource.DashboardEnabled = true;\n\n        configure(builder.Resource.Dashboard ?? throw new InvalidOperationException(\"Dashboard resource is not initialized\"));\n\n        return builder;\n    }\n}\n","sourceCodeStart":181,"sourceCodeEnd":204,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Docker/DockerComposeEnvironmentExtensions.cs#L181-L204","documentation":"WithDashboard enables the compose environment's dashboard and then configures it via the callback. If DashboardEnabled was never materialized into a Dashboard resource (it is null) the method throws InvalidOperationException, since there is nothing to configure. This typically means the dashboard resource was not initialized before WithDashboard was called.","triggerScenarios":"Calling WithDockerComposeDashboard/WithDashboard on a DockerComposeEnvironmentBuilder whose Resource.Dashboard is null — e.g. the dashboard resource is only created later or in a code path not executed for this environment.","commonSituations":"Calling dashboard configuration at the wrong point in the builder chain or in an older/broken code path where dashboard initialization was skipped; environment constructed manually or deserialized rather than through the standard factory.","solutions":["Ensure dashboard support is enabled through the supported API path so Resource.Dashboard gets initialized before calling WithDashboard.","Update the Aspire.Hosting.Docker package if a version bug skipped dashboard initialization.","If you do not need dashboard configuration, omit the WithDashboard call entirely (setting DashboardEnabled alone does not create it)."],"exampleFix":"// before (Dashboard not initialized)\nvar env = builder.AddDockerComposeEnvironment(\"env\");\nenv.WithDashboard(d => d.WithHost(\"0.0.0.0\"));\n// after: use the current API which initializes the dashboard when enabling it, e.g.\nvar env = builder.AddDockerComposeEnvironment(\"env\").WithDashboard(d => d.WithHost(\"0.0.0.0\"));","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"if (env.Resource.Dashboard is { } dashboard)\n{\n    configure(dashboard);\n}\nelse\n{\n    // dashboard not initialized; enable via the supported API path before configuring\n}","tryCatchPattern":null,"preventionTips":["Enable the dashboard through the standard builder API so it is initialized before configuration","Do not set DashboardEnabled manually without initializing Resource.Dashboard","Upgrade the package if a known version skipped dashboard initialization"],"tags":["docker-compose","dashboard","null","state"],"backgroundTag":"null-argument","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}