{"record":{"id":"c071567d9bdc9494","repo":"microsoft/aspire","slug":"azuresandboxoptions-autodeleteenabled-must-be-set-when","errorCode":null,"errorMessage":"AzureSandboxOptions.AutoDeleteEnabled must be set when configuring auto-delete interval or trigger.","messagePattern":"AzureSandboxOptions\\.AutoDeleteEnabled must be set when configuring auto-delete interval or trigger\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs","lineNumber":388,"sourceCode":"            options.AutoSuspendInterval,\n            nameof(AzureSandboxOptions.AutoSuspendInterval),\n            TimeSpan.FromSeconds(int.MaxValue));\n        ValidateOptionalEnum(options.AutoSuspendMode, nameof(AzureSandboxOptions.AutoSuspendMode));\n        ValidateOptionalWholeSecondDuration(options.AutoDeleteInterval, nameof(AzureSandboxOptions.AutoDeleteInterval));\n        ValidateOptionalEnum(options.AutoDeleteTrigger, nameof(AzureSandboxOptions.AutoDeleteTrigger));\n\n        if (options.AutoSuspendEnabled is null &&\n            (options.AutoSuspendInterval is not null || options.AutoSuspendMode is not null))\n        {\n            throw new ArgumentException(\n                $\"{nameof(AzureSandboxOptions.AutoSuspendEnabled)} must be set when configuring auto-suspend interval or mode.\",\n                nameof(options));\n        }\n\n        if (options.AutoDeleteEnabled is null &&\n            (options.AutoDeleteInterval is not null || options.AutoDeleteTrigger is not null))\n        {\n            throw new ArgumentException(\n                $\"{nameof(AzureSandboxOptions.AutoDeleteEnabled)} must be set when configuring auto-delete interval or trigger.\",\n                nameof(options));\n        }\n\n        if (options.Endpoints is null)\n        {\n            return;\n        }\n\n        var names = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\n        foreach (var endpoint in options.Endpoints)\n        {\n            if (endpoint is null)\n            {\n                throw new ArgumentException(\"Endpoint options cannot contain null values.\", nameof(options));\n            }\n\n            if (string.IsNullOrWhiteSpace(endpoint.Name))","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs#L370-L406","documentation":"Auto-delete was partially configured: an auto-delete interval and/or trigger was supplied, but the AutoDeleteEnabled master switch was left unset (null). The library requires the enabling flag to be explicit whenever any auto-delete detail is provided, and throws ArgumentException otherwise.","triggerScenarios":"Calling PublishAsAzureSandbox with AzureSandboxOptions where AutoDeleteEnabled is null while AutoDeleteInterval or AutoDeleteTrigger is non-null.","commonSituations":"Setting only AutoDeleteInterval or AutoDeleteTrigger and assuming auto-delete enables itself; options objects constructed from configuration where the Enabled flag key is missing; copy-paste of auto-suspend options renamed to auto-delete without the Enabled flag.","solutions":["Set AutoDeleteEnabled = true alongside the interval/trigger to opt into auto-delete.","If auto-delete is unwanted, remove the AutoDeleteInterval/AutoDeleteTrigger values.","Validate options before publishing: AutoDeleteEnabled must be non-null whenever either auto-delete detail is provided."],"exampleFix":"// before\nnew AzureSandboxOptions { AutoDeleteInterval = TimeSpan.FromDays(7) };\n\n// after\nnew AzureSandboxOptions\n{\n    AutoDeleteEnabled = true,\n    AutoDeleteInterval = TimeSpan.FromDays(7)\n};","handlingStrategy":"validation","validationCode":"if (options.AutoDeleteEnabled is null && (options.AutoDeleteInterval is not null || options.AutoDeleteTrigger is not null))\n{\n    throw new ArgumentException(\"AutoDeleteEnabled must be set when configuring auto-delete interval or trigger.\");\n}","typeGuard":null,"tryCatchPattern":"try { builder.PublishAsAzureSandbox(options); } catch (ArgumentException ex) when (ex.Message.Contains(\"AutoDeleteEnabled must be set\")) { /* set AutoDeleteEnabled or remove the interval/trigger */ }","preventionTips":["Treat Enabled flags as required companions of interval/trigger values in all option builders.","Add a shared options-validation helper covering both auto-suspend and auto-delete pairs.","When loading from configuration, ensure the Enabled keys exist whenever detail keys are present."],"tags":["azure","sandbox-group","validation","autodelete","configuration"],"backgroundTag":"missing-required-config-field","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"}