{"record":{"id":"48d3ba8320fa1386","repo":"dotnet/orleans","slug":"value-must-be-positive-or-timeout-infinitetimespan","errorCode":null,"errorMessage":"Value must be positive or Timeout.InfiniteTimeSpan.","messagePattern":"Value must be positive or Timeout\\.InfiniteTimeSpan\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Azure/Shared/Storage/AzureStoragePolicyOptions.cs","lineNumber":56,"sourceCode":"\n        public TimeSpan PauseBetweenCreationRetries { get; set; } = TimeSpan.FromSeconds(1);\n\n        /// <summary>\n        /// The base delay used by the Azure SDK exponential retry policy.\n        /// </summary>\n        public TimeSpan PauseBetweenOperationRetries { get; set; } = TimeSpan.FromSeconds(0.8);\n\n        /// <summary>\n        /// The maximum delay used by the Azure SDK exponential retry policy.\n        /// </summary>\n        public TimeSpan MaxPauseBetweenOperationRetries\n        {\n            get => this.maxPauseBetweenOperationRetries ?? TimeSpan.FromMinutes(1);\n            set\n            {\n                if (value <= TimeSpan.Zero && !value.Equals(Timeout.InfiniteTimeSpan))\n                {\n                    throw new ArgumentOutOfRangeException(nameof(MaxPauseBetweenOperationRetries), value, \"Value must be positive or Timeout.InfiniteTimeSpan.\");\n                }\n                this.maxPauseBetweenOperationRetries = value;\n            }\n        }\n\n        public TimeSpan CreationTimeout\n        {\n            get => this.creationTimeout ?? TimeSpan.FromMilliseconds(this.PauseBetweenCreationRetries.TotalMilliseconds * this.MaxCreationRetries * 3);\n            set => SetIfValidTimeout(ref this.creationTimeout, value, nameof(CreationTimeout));\n        }\n\n        public TimeSpan OperationTimeout\n        {\n            get => this.operationTimeout ?? TimeSpan.FromSeconds(100);\n            set => SetIfValidTimeout(ref this.operationTimeout, value, nameof(OperationTimeout));\n        }\n\n        private static void SetIfValidTimeout(ref TimeSpan? field, TimeSpan value, string propertyName)","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Shared/Storage/AzureStoragePolicyOptions.cs#L38-L74","documentation":"Thrown by the MaxPauseBetweenOperationRetries setter on AzureStoragePolicyOptions when the value is <= TimeSpan.Zero and is not Timeout.InfiniteTimeSpan. This bounds the Azure SDK exponential-retry ceiling; a non-positive finite value would make no sense, so it is rejected with an ArgumentOutOfRangeException. Defaults to 1 minute when unset.","triggerScenarios":"Assigning policy.MaxPauseBetweenOperationRetries = TimeSpan.Zero or a negative TimeSpan (e.g. TimeSpan.FromSeconds(-1)) in storage policy configuration.","commonSituations":"Misreading 0 as 'no cap'; computing a delay that underflows to negative; copying a config snippet that used TimeSpan.Zero intending 'default'.","solutions":["Set a positive TimeSpan (e.g. TimeSpan.FromMinutes(1)) or Timeout.InfiniteTimeSpan for no cap.","If you want the default, simply do not assign the property (it defaults to 1 minute).","Validate computed delay values before assignment."],"exampleFix":"// before\npolicy.MaxPauseBetweenOperationRetries = TimeSpan.Zero; // throws\n// after\npolicy.MaxPauseBetweenOperationRetries = TimeSpan.FromMinutes(1); // or leave unset for the default","handlingStrategy":"validation","validationCode":"static TimeSpan SafeMaxPause(TimeSpan v) =>\n    v > TimeSpan.Zero || v == Timeout.InfiniteTimeSpan ? v : throw new ArgumentOutOfRangeException(nameof(v));","typeGuard":"static bool IsValidMaxPause(TimeSpan v) => v > TimeSpan.Zero || v == Timeout.InfiniteTimeSpan;","tryCatchPattern":"catch (ArgumentOutOfRangeException ex) when (ex.Message.Contains(\"Value must be positive\")) { /* pass a positive TimeSpan or Infinite */ }","preventionTips":["Leave MaxPauseBetweenOperationRetries unset to use the 1-minute default.","Validate computed delays before assignment."],"tags":["orleans","azure-storage","configuration","retry","argument"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}