{"record":{"id":"cd3e7fee99e1eca5","repo":"TechnitiumSoftware/DnsServer","slug":"valid-range-is-from-1-to-10","errorCode":null,"errorMessage":"Valid range is from 1 to 10.","messagePattern":"Valid range is from 1 to 10\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/DnsServer.cs","lineNumber":7921,"sourceCode":"        public bool QnameMinimization\n        {\n            get { return _qnameMinimization; }\n            set { _qnameMinimization = value; }\n        }\n\n        public bool LocallyServedDnsZones\n        {\n            get { return _locallyServedDnsZones; }\n            set { _locallyServedDnsZones = value; }\n        }\n\n        public int ResolverRetries\n        {\n            get { return _resolverRetries; }\n            set\n            {\n                if ((value < 1) || (value > 10))\n                    throw new ArgumentOutOfRangeException(nameof(ResolverRetries), \"Valid range is from 1 to 10.\");\n\n                _resolverRetries = value;\n            }\n        }\n\n        public int ResolverTimeout\n        {\n            get { return _resolverTimeout; }\n            set\n            {\n                if ((value < 1000) || (value > 10000))\n                    throw new ArgumentOutOfRangeException(nameof(ResolverTimeout), \"Valid range is from 1000 to 10000.\");\n\n                _resolverTimeout = value;\n            }\n        }\n\n        public int ResolverConcurrency","sourceCodeStart":7903,"sourceCodeEnd":7939,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/DnsServer.cs#L7903-L7939","documentation":"Thrown by the ResolverRetries property setter when the value is outside [1, 10]. This controls how many times the internal resolver retries an upstream query before giving up. Values below 1 would disable retries entirely (not permitted) and above 10 would waste time on dead upstreams.","triggerScenarios":"Setting DnsServer.ResolverRetries to 0, a negative number, or any integer greater than 10.","commonSituations":"Configuring retries from a UI/env var without bounds checking; setting 0 expecting \"no retries\"; raising it high hoping for more resilience against flaky upstreams.","solutions":["Pick a value between 1 and 10 inclusive (2–3 is a sensible default for most setups).","If you wanted to minimize latency, use a lower value like 1–2 rather than 0.","Validate config-sourced integers with a range clamp before assignment."],"exampleFix":"// before\nserver.ResolverRetries = 0;\n\n// after\nserver.ResolverRetries = 2;","handlingStrategy":"validation","validationCode":"static int ClampRetries(int v) => Math.Clamp(v, 1, 10);\nserver.ResolverRetries = ClampRetries(configRetries);","typeGuard":"static bool IsValidResolverRetries(int v) => v >= 1 && v <= 10;","tryCatchPattern":"try { server.ResolverRetries = retries; }\ncatch (ArgumentOutOfRangeException) { server.ResolverRetries = 2; }","preventionTips":["Clamp all resolver tuning integers from config.","Document units and ranges next to each setting.","Unit-test config parsing against the documented bounds."],"tags":["dns","configuration","validation","resolver","limits"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}