{"record":{"id":"41ef07d105232485","repo":"TechnitiumSoftware/DnsServer","slug":"network-group-map-contains-an-invalid-network-addr","errorCode":null,"errorMessage":"Network group map contains an invalid network address: {network}","messagePattern":"Network group map contains an invalid network address: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Apps/AdvancedBlockingApp/App.cs","lineNumber":382,"sourceCode":"            _nsRecord = new DnsNSRecordData(_dnsServer.ServerDomain);\n\n            if (jsonConfig.TryReadObjectAsMap(\"localEndPointGroupMap\",\n                delegate (string localEP, JsonElement jsonGroup)\n                {\n                    if (!EndPointExtensions.TryParse(localEP, out EndPoint ep))\n                        throw new InvalidOperationException(\"Local end point group map contains an invalid end point: \" + localEP);\n\n                    return new Tuple<EndPoint, string>(ep, jsonGroup.GetString() ?? \"\");\n                },\n                out Dictionary<EndPoint, string>? localEndPointGroupMap))\n            {\n                _localEndPointGroupMap = localEndPointGroupMap;\n            }\n\n            _networkGroupMap = jsonConfig.ReadObjectAsMap(\"networkGroupMap\", delegate (string network, JsonElement jsonGroup)\n            {\n                if (!NetworkAddress.TryParse(network, out NetworkAddress networkAddress))\n                    throw new InvalidOperationException(\"Network group map contains an invalid network address: \" + network);\n\n                return new Tuple<NetworkAddress, string>(networkAddress, jsonGroup.GetString() ?? \"\");\n            });\n\n            {\n                Dictionary<Uri, BlockList> allAllowListZones = new Dictionary<Uri, BlockList>(0);\n                Dictionary<Uri, BlockList> allBlockListZones = new Dictionary<Uri, BlockList>(0);\n\n                Dictionary<Uri, RegexList> allRegexAllowListZones = new Dictionary<Uri, RegexList>(0);\n                Dictionary<Uri, RegexList> allRegexBlockListZones = new Dictionary<Uri, RegexList>(0);\n\n                Dictionary<Uri, AdBlockList> allAdBlockListZones = new Dictionary<Uri, AdBlockList>(0);\n\n                _groups = jsonConfig.ReadArrayAsMap(\"groups\", delegate (JsonElement jsonGroup)\n                {\n                    Group group = new Group(this, jsonGroup);\n\n                    foreach (Uri allowListUrl in group.AllowListUrls)","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/Apps/AdvancedBlockingApp/App.cs#L364-L400","documentation":"Thrown while parsing the AdvancedBlockingApp 'networkGroupMap' JSON object. Each key is parsed with NetworkAddress.TryParse, which expects a CIDR network address (e.g. '192.168.1.0/24' or '::/0'). A key that is not a valid network address raises InvalidOperationException during app initialization.","triggerScenarios":"Calling the AdvancedBlockingApp initializer with a 'networkGroupMap' key that NetworkAddress.TryParse rejects: a hostname, a bare host IP with no prefix length in a context requiring CIDR, a typo like '192.168.1.0//24', or an out-of-range octet.","commonSituations":"Pasting a client IP '10.0.0.5' instead of its subnet '10.0.0.0/24'; using DNS zone notation; trailing slash typos; mixing an endpoint (with ':port') into the network map.","solutions":["Edit dnsApp.config and correct the 'networkGroupMap' key to valid CIDR notation (e.g. '192.168.1.0/24', 'fe80::/64').","Ensure IPv4 keys carry an explicit prefix length; '/32' for a single host.","Keep endpoints (with ports) out of 'networkGroupMap' — those belong in 'localEndPointGroupMap'."],"exampleFix":"// before (dnsApp.config)\n\"networkGroupMap\": { \"192.168.1.5\": \"groupA\" }\n// after\n\"networkGroupMap\": { \"192.168.1.0/24\": \"groupA\" }","handlingStrategy":"validation","validationCode":"foreach (string key in networkGroupMapKeys)\n{\n    if (!NetworkAddress.TryParse(key, out NetworkAddress _))\n        throw new FormatException($\"'networkGroupMap' key '{key}' is not a valid CIDR network. Expected e.g. '192.168.1.0/24'.\");\n}","typeGuard":"static bool IsValidCidrKey(string key) => NetworkAddress.TryParse(key, out NetworkAddress _);","tryCatchPattern":null,"preventionTips":["Use CIDR notation with an explicit prefix length for all network map keys.","Use '/32' or '/128' for single hosts; never append a port.","Run the DNS server's config validation/preview before applying changes."],"tags":["csharp","config","json","cidr","network","technitium","advanced-blocking-app"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}