{"record":{"id":"9d7ee21d30596193","repo":"HangfireIO/Hangfire","slug":"options-9d7ee2","errorCode":null,"errorMessage":"options","messagePattern":"options","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/Processing/BackgroundExecution.cs","lineNumber":55,"sourceCode":"        private readonly ManualResetEvent _stopped = new ManualResetEvent(false);\n        private Stopwatch _faultedSince;\n        private Stopwatch _failedSince;\n        private Stopwatch _lastException;\n        private int _exceptionsCount;\n\n        private CancellationToken _stopToken;\n        private readonly BackgroundExecutionOptions _options;\n        private readonly ILog _logger;\n\n        private readonly Stopwatch _createdAt;\n        private Stopwatch _stoppedAt;\n        private CancellationTokenRegistration _stopRegistration;\n\n        private volatile bool _disposed;\n\n        public BackgroundExecution([NotNull] BackgroundExecutionOptions options, CancellationToken stopToken)\n        {\n            _options = options ?? throw new ArgumentNullException(nameof(options));\n\n            _logger = LogProvider.GetLogger(GetType());\n            _createdAt = Stopwatch.StartNew();\n\n            _stopToken = stopToken;\n\n            _stopRegistration = _stopToken.Register(SetStoppedAt);\n\n#if !NETSTANDARD1_3\n            AppDomainUnloadMonitor.EnsureInitialized();\n#endif\n        }\n\n        public bool StopRequested => _disposed || _stopToken.IsCancellationRequested;\n\n        public void Run(Action<Guid, object> callback, object state)\n        {\n            if (callback == null) throw new ArgumentNullException(nameof(callback));","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/Processing/BackgroundExecution.cs#L37-L73","documentation":"Thrown by the BackgroundExecution constructor (internal) when the BackgroundExecutionOptions argument is null. Options carry the warning/error thresholds and retry-delay function used throughout the execution loop, so a null options object would NRE on every state transition.","triggerScenarios":"Constructing BackgroundExecution with options == null. Reached when server wiring passes null instead of a BackgroundExecutionOptions instance.","commonSituations":"A factory method that builds execution returned null options; a code path that constructs BackgroundExecution before initializing its options; refactoring that dropped the options argument.","solutions":["Pass a non-null BackgroundExecutionOptions — create one with `new BackgroundExecutionOptions()` if defaults are acceptable.","Guard at the call site: fail fast with a descriptive message if options is null before constructing.","Ensure the code that owns options lifecycle initializes it before the execution."],"exampleFix":"// before\nvar execution = new BackgroundExecution(null, stopToken);\n\n// after\nvar options = options ?? new BackgroundExecutionOptions();\nvar execution = new BackgroundExecution(options, stopToken);","handlingStrategy":"validation","validationCode":"var options = configuredOptions ?? new BackgroundExecutionOptions();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always construct BackgroundExecutionOptions before BackgroundExecution.","Use the parameterless options ctor for sensible defaults.","Guard factory methods that produce options against returning null."],"tags":["hangfire","null-argument","argument-validation","background-processing"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}