{"record":{"id":"2a006f61d42215a2","repo":"TechnitiumSoftware/DnsServer","slug":"lease-time-in-days-must-be-between-0-to-999","errorCode":null,"errorMessage":"Lease time in days must be between 0 to 999.","messagePattern":"Lease time in days must be between 0 to 999\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dhcp/Scope.cs","lineNumber":1886,"sourceCode":"        public bool Enabled\n        { get { return _enabled; } }\n\n        public IPAddress StartingAddress\n        { get { return _startingAddress; } }\n\n        public IPAddress EndingAddress\n        { get { return _endingAddress; } }\n\n        public IPAddress SubnetMask\n        { get { return _subnetMask; } }\n\n        public ushort LeaseTimeDays\n        {\n            get { return _leaseTimeDays; }\n            set\n            {\n                if (value > 999)\n                    throw new ArgumentOutOfRangeException(nameof(LeaseTimeDays), \"Lease time in days must be between 0 to 999.\");\n\n                _leaseTimeDays = value;\n            }\n        }\n\n        public byte LeaseTimeHours\n        {\n            get { return _leaseTimeHours; }\n            set\n            {\n                if (value > 23)\n                    throw new ArgumentOutOfRangeException(nameof(LeaseTimeHours), \"Lease time in hours must be between 0 to 23.\");\n\n                _leaseTimeHours = value;\n            }\n        }\n\n        public byte LeaseTimeMinutes","sourceCodeStart":1868,"sourceCodeEnd":1904,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/Scope.cs#L1868-L1904","documentation":"Thrown by the LeaseTimeDays setter (ushort) when the value exceeds 999. The lease time is serialized/stored with a 3-digit cap, so values above 999 days are rejected as out of the supported range.","triggerScenarios":"Assigning scope.LeaseTimeDays = value where value > 999. Common with config deserialization feeding an unchecked integer, or a UI allowing thousands of days.","commonSituations":"Importing a config with a huge lease lifetime, unit confusion (passing seconds/days), or a slider without an upper bound.","solutions":["Clamp the input to the 0..999 range before assignment.","Reject or warn on values above 999 in your config validation layer.","If a longer lease is genuinely needed, note the library hard-caps at 999 days.","Double-check units: the field is days, not seconds or hours."],"exampleFix":"// before\nscope.LeaseTimeDays = (ushort)configDays; // throws if > 999\n\n// after\nscope.LeaseTimeDays = (ushort)Math.Min(configDays, 999);","handlingStrategy":"validation","validationCode":"if (days > 999) throw new ConfigurationException(\"LeaseTimeDays must be <= 999\");\nscope.LeaseTimeDays = (ushort)Math.Clamp(days, 0, 999);","typeGuard":"static bool IsValidLeaseTimeDays(int days) => days >= 0 && days <= 999;","tryCatchPattern":"try { scope.LeaseTimeDays = value; }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"LeaseTimeDays\")\n{ /* clamp and retry, or report to user */ }","preventionTips":["Bound the lease-time input in your UI/config schema to 0..999.","Document that the field is in days, not seconds.","Unit-test deserialization with extreme values."],"tags":["dhcp","validation","scope","lease-time","argument"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}