{"record":{"id":"f7f7f3a802c6b0b1","repo":"TechnitiumSoftware/DnsServer","slug":"value-must-be-between-1-hour-and-168-hours-7-days","errorCode":null,"errorMessage":"Value must be between 1 hour and 168 hours (7 days) or 0 to disable automatic update.","messagePattern":"Value must be between 1 hour and 168 hours \\(7 days\\) or 0 to disable automatic update\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs","lineNumber":1088,"sourceCode":"                    }\n\n                    if (uniqueList.Count == commentCount)\n                        uniqueList = [];\n\n                    value = uniqueList;\n                }\n\n                ApplyBlockListUrls(value);\n            }\n        }\n\n        public int BlockListUpdateIntervalHours\n        {\n            get { return _blockListUpdateIntervalHours; }\n            set\n            {\n                if ((value < 0) || (value > 168))\n                    throw new ArgumentOutOfRangeException(nameof(BlockListUpdateIntervalHours), \"Value must be between 1 hour and 168 hours (7 days) or 0 to disable automatic update.\");\n\n                _blockListUpdateIntervalHours = value;\n\n                ApplyBlockListUpdateInterval();\n            }\n        }\n\n        public bool BlockListUpdateEnabled\n        { get { return _blockListUpdateTimer is not null; } }\n\n        public DateTime BlockListLastUpdatedOn\n        {\n            get { return _blockListLastUpdatedOn; }\n            internal set\n            {\n                _blockListLastUpdatedOn = value;\n            }\n        }","sourceCodeStart":1070,"sourceCodeEnd":1106,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs#L1070-L1106","documentation":"Thrown by the BlockListUpdateIntervalHours setter when value is < 0 or > 168. The valid range is 0 (disable automatic update) up to 168 hours (7 days); values outside that are an ArgumentOutOfRangeException.","triggerScenarios":"Setting the auto-update interval to a negative number; setting it above 168 (e.g. 200 hours, or treating the field as minutes/days by mistake).","commonSituations":"Unit confusion (passing minutes or days into an hours field); config import with a stale/out-of-range value; script computing the interval arithmetically and overflowing.","solutions":["Pass a value in [0, 168] hours (e.g. 24 for daily, 0 to disable).","If you intended a longer interval, choose 168 (the max) and rely on manual updates beyond that.","Double-check the unit is hours, not minutes."],"exampleFix":"// before\nblockListZoneManager.BlockListUpdateIntervalHours = 240; // > 168 -> throws\n// after\nblockListZoneManager.BlockListUpdateIntervalHours = 168; // max = 7 days, or 0 to disable","handlingStrategy":"validation","validationCode":"const int MaxHours = 168;\nint hours = Math.Clamp(requestedHours, 0, MaxHours);\nblockListZoneManager.BlockListUpdateIntervalHours = hours;","typeGuard":"static bool IsValidUpdateInterval(int hours) => hours >= 0 && hours <= 168;","tryCatchPattern":"try { blockListZoneManager.BlockListUpdateIntervalHours = hours; }\ncatch (ArgumentOutOfRangeException) { blockListZoneManager.BlockListUpdateIntervalHours = Math.Clamp(hours, 0, 168); }","preventionTips":["Remember the field is HOURS, not minutes or days.","Use 0 to disable automatic updates explicitly.","Clamp user-supplied values at the configuration boundary.","Document the 0..168 range in your config UI."],"tags":["dns","blocklist","validation","configuration"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}