{"record":{"id":"3f9a27ba400e8e4a","repo":"microsoft/aspire","slug":"deployment-state-section-section-sectionname-is-missing","errorCode":null,"errorMessage":"Deployment state section '{section.SectionName}' is missing required value '{name}'.","messagePattern":"Deployment state section '(.+?)' is missing required value '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs","lineNumber":2307,"sourceCode":"    {\n        var effectiveCancellationToken = cancellationToken ?? context.CancellationToken;\n        try\n        {\n            await client.DeleteDiskImageAsync(scope, diskImageId, effectiveCancellationToken).ConfigureAwait(false);\n        }\n        catch (Exception ex) when (!throwOnError &&\n            (ex is not OperationCanceledException || !effectiveCancellationToken.IsCancellationRequested))\n        {\n            context.Logger.LogWarning(ex, \"Failed to delete sandbox disk image '{DiskImageId}'.\", diskImageId);\n        }\n    }\n\n    private static string GetRequiredStateValue(DeploymentStateSection section, string name)\n    {\n        var value = section.Data[name]?.GetValue<string>();\n        if (string.IsNullOrWhiteSpace(value))\n        {\n            throw new InvalidOperationException($\"Deployment state section '{section.SectionName}' is missing required value '{name}'.\");\n        }\n\n        return value;\n    }\n\n    private static string GetRequiredOutput(AzureBicepResource resource, string name)\n    {\n        if (!resource.Outputs.TryGetValue(name, out var value) || value is null || string.IsNullOrWhiteSpace(value.ToString()))\n        {\n            throw new InvalidOperationException($\"Azure resource '{resource.Name}' is missing required output '{name}'. Ensure Azure infrastructure provisioning completed successfully.\");\n        }\n\n        return value.ToString()!;\n    }\n\n    internal static AzureDevComputeResourceScope CreateDataPlaneScope(AzureSandboxGroupResource sandboxGroup)\n    {\n        ArgumentNullException.ThrowIfNull(sandboxGroup);","sourceCodeStart":2289,"sourceCodeEnd":2325,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs#L2289-L2325","documentation":"Thrown by GetRequiredStateValue when a required key is absent or blank in a section of the persisted sandbox deployment state. The library treats the deployment state file as the source of truth and refuses to continue with an empty required value.","triggerScenarios":"Calling GetRequiredStateValue(section, name) where `section.Data[name]` is null, whitespace, or not a string; e.g. reading outputs like subscription/resource-group names from a section that was never populated.","commonSituations":"Deployment state file truncated, hand-edited, or written by an older Aspire version with a different schema; provisioning completed but the state section was never written; wrong section name requested.","solutions":["Re-run the Azure sandbox deployment so the deployment state is regenerated with all required values.","Inspect the deployment state section in the file and confirm the named key exists and has a non-empty string value.","Verify you are reading the correct DeploymentStateSection; a typo in the section or value name yields this error.","If the state file is stale or from an older schema version, delete it and redeploy the sandbox."],"exampleFix":"// before (state file missing key)\n{ \"Sandbox\": { } }\n// after (key present)\n{ \"Sandbox\": { \"ResourceGroupName\": \"rg-sandbox-abc\" } }","handlingStrategy":"validation","validationCode":"bool HasRequiredValue(DeploymentStateSection section, string name) =>\n    section.Data.TryGetValue(name, out var v) && !string.IsNullOrWhiteSpace(v?.GetValue<string>());","typeGuard":null,"tryCatchPattern":"try { var v = GetRequiredStateValue(section, name); }\ncatch (InvalidOperationException ex) { logger.LogError(ex, \"Missing deployment state value '{Name}'\", name); throw; }","preventionTips":["Never hand-edit the deployment state file.","Regenerate deployment state after upgrading Aspire versions.","Confirm provisioning completed before reading state sections."],"tags":["azure","deployment-state","missing-value","state"],"backgroundTag":"missing-config-value","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}