{"record":{"id":"c0b9be10b59b3588","repo":"HangfireIO/Hangfire","slug":"delaysinseconds-value-must-be-an-array-of-non-nega","errorCode":null,"errorMessage":"DelaysInSeconds value must be an array of non-negative numbers.","messagePattern":"DelaysInSeconds value must be an array of non-negative numbers\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/AutomaticRetryAttribute.cs","lineNumber":157,"sourceCode":"        }\n\n        /// <summary>\n        /// Gets or sets the delays between attempts.\n        /// </summary>\n        /// <value>An array of non-negative numbers.</value>\n        /// <exception cref=\"ArgumentNullException\">The value in a set operation is null.</exception>\n        /// <exception cref=\"ArgumentException\">The value contain one or more negative numbers.</exception>\n        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]\n        public int[] DelaysInSeconds\n        {\n            get { lock (_lockObject) { return _delaysInSeconds; } }\n            set\n            {\n                if (value != null)\n                {\n                    if (value.Length == 0) throw new ArgumentNullException(nameof(value));\n                    if (value.Any(static delay => delay < 0))\n                        throw new ArgumentException(\n                            $@\"{nameof(DelaysInSeconds)} value must be an array of non-negative numbers.\",\n                            nameof(value));\n                }\n\n                lock (_lockObject) { _delaysInSeconds = value; }\n            }\n        }\n\n        /// <summary>\n        /// Gets or sets a function using to get a delay by an attempt number.\n        /// </summary>\n        /// <exception cref=\"ArgumentNullException\">The value in a set operation is null.</exception>\n        [JsonIgnore]\n        public Func<long, int> DelayInSecondsByAttemptFunc\n        {\n            get { lock (_lockObject) { return _delayInSecondsByAttemptFunc;} }\n            set\n            {","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/AutomaticRetryAttribute.cs#L139-L175","documentation":"The DelaysInSeconds property on AutomaticRetryAttribute lets you specify an explicit per-attempt delay array instead of the default exponential backoff. Each element must be a non-negative integer; a null value is allowed (reverts to default), but an empty array or any negative element throws ArgumentException. This is assignment-time validation on the configuration property.","triggerScenarios":"Setting [AutomaticRetry(DelaysInSeconds = new[]{-5, 10})] or DelaysInSeconds = new int[0]. A null assignment is permitted (uses default backoff); only non-null arrays with empty/negative elements throw.","commonSituations":"Loading delay values from JSON/YAML config that maps missing values to -1 or 0-length arrays; mixing up the order of delays; intending 'no delay' but using -1 instead of 0.","solutions":["Replace negative values with 0 (zero-second delay) for immediate retries, or use positive seconds for real delays.","Ensure the array is non-empty when non-null — provide at least as many entries as Attempts, or use the default backoff by leaving DelaysInSeconds null.","Sanitize config arrays before assignment: filter out negatives and guard against empty."],"exampleFix":"// before\n[AutomaticRetry(Attempts = 3, DelaysInSeconds = new[]{-1, 5, 10})]\n\n// after\n[AutomaticRetry(Attempts = 3, DelaysInSeconds = new[]{0, 5, 10})]","handlingStrategy":"validation","validationCode":"int[] delays = LoadDelays();\nif (delays != null && (delays.Length == 0 || delays.Any(d => d < 0)))\n    delays = null; // fall back to default backoff\nattribute.DelaysInSeconds = delays;","typeGuard":"static bool IsValidDelays(int[] value) =>\n    value == null || (value.Length > 0 && value.All(d => d >= 0));","tryCatchPattern":null,"preventionTips":["Allow null to use the built-in exponential backoff.","Use 0 (not -1) for an immediate retry with no delay.","Validate arrays loaded from config before assignment."],"tags":["configuration","validation","retry","argumentexception","attribute"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}