{"record":{"id":"9bc4b30c1de81ca8","repo":"microsoft/aspire","slug":"propertyname-exceeds-the-maximum-supported-adc-interval","errorCode":null,"errorMessage":"{propertyName} exceeds the maximum supported ADC interval.","messagePattern":"(.+?) exceeds the maximum supported ADC interval\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs","lineNumber":621,"sourceCode":"        };\n    }\n\n    private static int? ToInt32Seconds(TimeSpan? value, string propertyName)\n    {\n        if (value is null)\n        {\n            return null;\n        }\n\n        if (value < TimeSpan.Zero || value.Value.Ticks % TimeSpan.TicksPerSecond != 0)\n        {\n            throw new InvalidOperationException($\"{propertyName} must be a non-negative whole-second duration.\");\n        }\n\n        var seconds = value.Value.Ticks / TimeSpan.TicksPerSecond;\n        return seconds <= int.MaxValue\n            ? (int)seconds\n            : throw new InvalidOperationException($\"{propertyName} exceeds the maximum supported ADC interval.\");\n    }\n\n    private static long? ToInt64Seconds(TimeSpan? value, string propertyName)\n    {\n        if (value is null)\n        {\n            return null;\n        }\n\n        if (value < TimeSpan.Zero || value.Value.Ticks % TimeSpan.TicksPerSecond != 0)\n        {\n            throw new InvalidOperationException($\"{propertyName} must be a non-negative whole-second duration.\");\n        }\n\n        return value.Value.Ticks / TimeSpan.TicksPerSecond;\n    }\n\n    private static async Task<AzureDevComputeDiskImage> CreateDiskImageAsync(","sourceCodeStart":603,"sourceCodeEnd":639,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs#L603-L639","documentation":"ADC lifecycle policy intervals are stored as 32-bit second counts; ToInt32Seconds throws InvalidOperationException when the supplied TimeSpan exceeds int.MaxValue seconds (~68 years) — practically signaling a nonsensical or mis-scaled interval for an ADC property.","triggerScenarios":"Passing a TimeSpan larger than 2,147,483,647 seconds (e.g. TimeSpan.MaxValue, or a value accidentally multiplied by 1000) to a CreateLifecyclePolicy property backed by ToInt32Seconds.","commonSituations":"Unit confusion such as treating the config value as milliseconds but constructing TimeSpan.FromSeconds, or reading an unbounded/garbage value from configuration.","solutions":["Reduce the interval to a realistic value (seconds to days range) appropriate for the ADC policy.","Check unit scaling of the incoming config value; fix any accidental multiplier.","If a genuinely large duration is required, use a property/overload accepting int64 seconds (ToInt64Seconds path)."],"exampleFix":"// before\npolicy.Retention = TimeSpan.FromTicks(TimeSpan.TicksPerDay * 10000000); // absurd\n// after\npolicy.Retention = TimeSpan.FromDays(30);","handlingStrategy":"validation","validationCode":"static TimeSpan ClampToInt32Seconds(TimeSpan t) =>\n    t.TotalSeconds > int.MaxValue ? TimeSpan.FromSeconds(int.MaxValue) : t;","typeGuard":null,"tryCatchPattern":"try { policy.Retention = parsed; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"maximum supported ADC interval\"))\n{ /* fix unit scaling of the source value, then retry */ }","preventionTips":["Audit unit scaling when converting config values (ms vs s).","Sanity-check durations against realistic ADC ranges before assignment.","Use int64-backed properties for genuinely large durations."],"tags":["azure","sandboxes","duration","range"],"backgroundTag":"value-out-of-range","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"}