{"record":{"id":"7bbe5bda25d8c69a","repo":"HangfireIO/Hangfire","slug":"the-queuepollinterval-property-value-should-be-pos","errorCode":null,"errorMessage":"The QueuePollInterval property value should be positive. Given: {value}.","messagePattern":"The QueuePollInterval property value should be positive\\. Given: (.+?)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.SqlServer/SqlServerStorageOptions.cs","lineNumber":101,"sourceCode":"                }\n            }\n\n            return null;\n        }\n\n        [Obsolete(\"TransactionIsolationLevel option is deprecated, please set UseRecommendedIsolationLevel instead. Will be removed in 2.0.0.\")]\n        public IsolationLevel? TransactionIsolationLevel { get; set; }\n\n        public TimeSpan QueuePollInterval\n        {\n            get { return _queuePollInterval; }\n            set\n            {\n                var message = $\"The QueuePollInterval property value should be positive. Given: {value}.\";\n\n                if (value != value.Duration())\n                {\n                    throw new ArgumentException(message, nameof(value));\n                }\n\n                _queuePollInterval = value;\n            }\n        }\n\n        [Obsolete(\"Does not make sense anymore. Background jobs re-queued instantly even after ungraceful shutdown now. Will be removed in 2.0.0.\")]\n        public TimeSpan InvisibilityTimeout { get; set; }\n\n        public TimeSpan? SlidingInvisibilityTimeout\n        {\n            get { return _slidingInvisibilityTimeout; }\n            set\n            {\n                if (value <= TimeSpan.Zero)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), \"Sliding timeout should be greater than zero\");\n                }","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.SqlServer/SqlServerStorageOptions.cs#L83-L119","documentation":"SqlServerStorageOptions.QueuePollInterval was set to a negative TimeSpan, which is invalid. The setter checks value != value.Duration() — Duration() returns the absolute value, so any negative TimeSpan triggers ArgumentException. QueuePollInterval controls how frequently the server polls the job queue when it is empty.","triggerScenarios":"Passing TimeSpan.FromTicks(-1), TimeSpan.FromSeconds(-1), or any negative TimeSpan to the QueuePollInterval setter; computing the interval from a subtraction that can go negative.","commonSituations":"Configuring poll intervals from dynamic values (e.g., config-driven durations) where a negative number leaks through; copying example code that uses a subtraction without clamping; accidental sign error.","solutions":["Use a positive TimeSpan value such as TimeSpan.FromSeconds(1) or TimeSpan.FromMilliseconds(500).","If the value comes from configuration, validate or clamp it to TimeSpan.Zero or a small positive minimum before assigning.","Use value.Duration() yourself if you want to tolerate negative input, but prefer fixing the source of the negative value."],"exampleFix":"// before\noptions.QueuePollInterval = TimeSpan.FromSeconds(myConfigValue); // myConfigValue can be -1\n// after — clamp to positive\noptions.QueuePollInterval = TimeSpan.FromSeconds(Math.Max(0, myConfigValue));","handlingStrategy":"validation","validationCode":"TimeSpan interval = /* from config or computation */;\nif (interval < TimeSpan.Zero)\n    throw new ArgumentOutOfRangeException(nameof(interval), \"QueuePollInterval must be non-negative.\");\n\noptions.QueuePollInterval = interval;","typeGuard":"static bool IsValidPollInterval(TimeSpan value) => value >= TimeSpan.Zero;","tryCatchPattern":null,"preventionTips":["Always use positive TimeSpan factory methods (FromSeconds, FromMilliseconds) for poll intervals.","Clamp config-sourced values to a minimum of TimeSpan.Zero.","Unit-test option configuration with edge-case values."],"tags":["options","validation","timespan","configuration"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}