{"record":{"id":"246d96431ff818fe","repo":"HangfireIO/Hangfire","slug":"value-246d96","errorCode":null,"errorMessage":"value","messagePattern":"value","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/Processing/BackgroundExecutionOptions.cs","lineNumber":73,"sourceCode":"            }\n        }\n\n        public TimeSpan StillErrorThreshold\n        {\n            get { return _stillErrorThreshold; }\n            set\n            {\n                if (value < TimeSpan.Zero) throw new ArgumentOutOfRangeException(nameof(value), \"Value should be greater than or equal to TimeSpan.Zero\");\n                _stillErrorThreshold = value;\n            }\n        }\n\n        public Func<int, TimeSpan> RetryDelay\n        {\n            get { return _retryDelay; }\n            set\n            {\n                if (value == null) throw new ArgumentNullException(nameof(value));\n                _retryDelay = value;\n            }\n        }\n\n        internal static TimeSpan GetBackOffMultiplier(int retryAttemptNumber)\n        {\n            //exponential/random retry back-off.\n            var rand = new Random(Guid.NewGuid().GetHashCode());\n            var nextTry = rand.Next(\n                (int)Math.Pow(retryAttemptNumber, 2), (int)Math.Pow(retryAttemptNumber, 2) + 1);\n\n            return TimeSpan.FromSeconds(Math.Min(nextTry, DefaultMaxAttemptDelay.TotalSeconds));\n        }\n    }\n}\n","sourceCodeStart":55,"sourceCodeEnd":89,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/Processing/BackgroundExecutionOptions.cs#L55-L89","documentation":"Thrown by the BackgroundExecutionOptions.RetryDelay setter (internal) when the assigned Func<int, TimeSpan> is null. RetryDelay computes the back-off between retry attempts in the execution loop; a null function would NRE on every exception.","triggerScenarios":"Assigning options.RetryDelay = null. Reached when configuration explicitly clears the retry-delay function or a binding fails to resolve it.","commonSituations":"Code that sets RetryDelay conditionally and falls through to null; a refactor that replaced the function with null instead of a no-op; deserialisation that omits the function.","solutions":["Assign a non-null Func<int, TimeSpan> — use BackgroundExecutionOptions.GetBackOffMultiplier for the default exponential back-off.","If you need a constant delay, supply `_ => TimeSpan.FromSeconds(5)` rather than null.","Guard configuration: replace null with the default function before assignment."],"exampleFix":"// before\noptions.RetryDelay = null;\n\n// after\noptions.RetryDelay = attempt => TimeSpan.FromSeconds(Math.Min(attempt * attempt, 300));","handlingStrategy":"validation","validationCode":"options.RetryDelay = configuredDelay ?? BackgroundExecutionOptions.GetBackOffMultiplier;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never assign null to RetryDelay — supply a real Func<int, TimeSpan>.","Use GetBackOffMultiplier for the built-in exponential back-off.","For constant delays use `_ => TimeSpan.FromSeconds(n)`."],"tags":["hangfire","null-argument","argument-validation","configuration","background-processing"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}