{"record":{"id":"bea54adec0fdf882","repo":"TechnitiumSoftware/DnsServer","slug":"cannot-configure-more-than-255-block-list-urls","errorCode":null,"errorMessage":"Cannot configure more than 255 block list URLs.","messagePattern":"Cannot configure more than 255 block list URLs\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs","lineNumber":1036,"sourceCode":"                temporaryDisableBlockingTimer.Dispose();\n        }\n\n        #endregion\n\n        #region properties\n\n        public IReadOnlyList<string> BlockListUrls\n        {\n            get { return _blockListUrls; }\n            set\n            {\n                if (value is null)\n                {\n                    value = [];\n                }\n                else if (value.Count > 255)\n                {\n                    throw new ArgumentException(\"Cannot configure more than 255 block list URLs.\", nameof(BlockListUrls));\n                }\n                else\n                {\n                    List<string> uniqueList = new List<string>(value.Count);\n                    int commentCount = 0;\n\n                    foreach (string url in value)\n                    {\n                        if (url.Length > 255)\n                            throw new ArgumentException(\"Block list URL (or comment line) length cannot exceed 255 characters.\", nameof(BlockListUrls));\n\n                        if (url.TrimStart().StartsWith('#'))\n                        {\n                            uniqueList.Add(url);\n                            commentCount++;\n                            continue;\n                        }\n","sourceCodeStart":1018,"sourceCodeEnd":1054,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs#L1018-L1054","documentation":"Thrown by the BlockListUrls property setter when more than 255 entries are supplied. The count is persisted as a single byte (bW.Write(Convert.ToByte(_blockListUrls.Count))), so the cap is hard 255. Null is allowed (treated as empty), but any non-null collection over 255 is rejected.","triggerScenarios":"Assigning an IReadOnlyList<string> with Count > 255 to BlockListUrls; bulk-loading a large subscription list that exceeds the byte-width limit.","commonSituations":"Operator subscribes to many ad-block / malware block list feeds exceeding 255 combined entries; merging several lists into one configured set.","solutions":["Trim the list to at most 255 URLs (prefer deduplicating first to reclaim slots).","Consolidate multiple small lists into fewer combined upstream lists.","Offload excess blocking to a DNS RPZ or blocked-zone rule set instead of the URL-based block list."],"exampleFix":"// before\nblockListZoneManager.BlockListUrls = allUrls; // Count == 300 -> throws\n// after\nblockListZoneManager.BlockListUrls = allUrls.Distinct().Take(255).ToList();","handlingStrategy":"validation","validationCode":"if (urls != null && urls.Count > 255)\n    throw new InvalidOperationException($\"Trim block list URLs to <= 255 (got {urls.Count}).\");\nblockListZoneManager.BlockListUrls = urls;","typeGuard":"static bool IsValidBlockListUrlCount(IReadOnlyList<string> urls) => urls is null || urls.Count <= 255;","tryCatchPattern":"try { blockListZoneManager.BlockListUrls = urls; }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"255 block list URLs\"))\n{ blockListZoneManager.BlockListUrls = urls.Distinct().Take(255).ToList(); }","preventionTips":["Deduplicate the list before assigning to reclaim slots.","Cap input at 255 at the configuration/UI boundary.","Track list size as a metric so you notice before hitting the limit.","Prefer fewer combined upstream lists over many small ones."],"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"}