{"record":{"id":"6f1e7ea8c4c91e43","repo":"HangfireIO/Hangfire","slug":"value","errorCode":null,"errorMessage":"value","messagePattern":"value","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/BackgroundJobServerOptions.cs","lineNumber":83,"sourceCode":"        public bool IsLightweightServer { get; set; }\n\n        public int WorkerCount\n        {\n            get { return _workerCount; }\n            set\n            {\n                if (value <= 0) throw new ArgumentOutOfRangeException(nameof(value), \"WorkerCount property value should be positive.\");\n\n                _workerCount = value;\n            }\n        }\n\n        public string[] Queues\n        {\n            get { return _queues; }\n            set\n            {\n                if (value == null) throw new ArgumentNullException(nameof(value));\n                if (value.Length == 0) throw new ArgumentException(\"You should specify at least one queue to listen.\", nameof(value));\n\n                _queues = value;\n            }\n        }\n\n        public TimeSpan StopTimeout\n        {\n            get => _stopTimeout;\n            set\n            {\n                if ((value < TimeSpan.Zero && value != Timeout.InfiniteTimeSpan) || value.TotalMilliseconds > Int32.MaxValue)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), $\"StopTimeout must be either equal to or less than {Int32.MaxValue} milliseconds and non-negative or infinite\");\n                }\n                _stopTimeout = value;\n            }\n        }","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/BackgroundJobServerOptions.cs#L65-L101","documentation":"This exception (ArgumentNullException(\"value\") or ArgumentException(\"You should specify at least one queue to listen.\") in the same setter) is thrown by the Queues setter of BackgroundJobServerOptions when the supplied string[] is null (ArgumentNullException) or empty (ArgumentException). The server must subscribe to at least one queue to fetch jobs from; the default is { EnqueuedState.DefaultQueue } (\"default\").","triggerScenarios":"Assigning options.Queues = null; assigning options.Queues = Array.Empty<string>() or new string[0]; binding from a config section that produced no entries.","commonSituations":"Configuration binding for Queues returns an empty array when the section is absent; a code path that conditionally sets Queues only when a feature flag is on, leaving it null; tests that initialize Queues to an empty list; refactor that removed the default queue.","solutions":["Provide at least one queue name, e.g. options.Queues = new[] { \"default\", \"critical\" }.","Coerce config: if the parsed list is null/empty, fall back to new[] { EnqueuedState.DefaultQueue }.","Do not assign Queues at all to keep the default (\"default\").","Validate the queue list at startup before constructing the server."],"exampleFix":"// before\noptions.Queues = config.GetSection(\"Queues\").Get<string[]>(); // null when missing\n\n// after\nvar queues = config.GetSection(\"Queues\").Get<string[]>();\noptions.Queues = queues is { Length: > 0 } ? queues : new[] { EnqueuedState.DefaultQueue };","handlingStrategy":"validation","validationCode":"var queues = config.GetSection(\"Queues\").Get<string[]>();\noptions.Queues = queues is { Length: > 0 } ? queues : new[] { EnqueuedState.DefaultQueue };","typeGuard":"static bool AreQueuesValid(string[] queues) => queues is { Length: > 0 };","tryCatchPattern":"try { options.Queues = queues; }\ncatch (ArgumentException) { options.Queues = new[] { EnqueuedState.DefaultQueue }; }","preventionTips":["Fall back to the default queue when config is missing.","Validate the queue list at startup.","Do not assign null or empty arrays."],"tags":["csharp","hangfire","argumentexception","argumentnullexception","configuration","queues","validation","background-jobs"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}