{"record":{"id":"2ed363524a4a24b5","repo":"TechnitiumSoftware/DnsServer","slug":"unexpected-url-format-jsonurl-valuekind","errorCode":null,"errorMessage":"Unexpected URL format: {jsonUrl.ValueKind}","messagePattern":"Unexpected URL format: (.+?)","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"Apps/AdvancedBlockingApp/App.cs","lineNumber":797,"sourceCode":"                                            aaaaRecords.Add(new DnsAAAARecordData(address));\n                                            break;\n                                    }\n                                }\n                            }\n\n                            _aRecords = aRecords.Count > 0 ? aRecords : group.ARecords;\n                            _aaaaRecords = aaaaRecords.Count > 0 ? aaaaRecords : group.AAAARecords;\n                        }\n                        else\n                        {\n                            _aRecords = group.ARecords;\n                            _aaaaRecords = group.AAAARecords;\n                        }\n\n                        break;\n\n                    default:\n                        throw new InvalidDataException(\"Unexpected URL format: \" + jsonUrl.ValueKind);\n                }\n            }\n\n            #endregion\n\n            #region properties\n\n            public Uri? Uri\n            { get { return _uri; } }\n\n            public bool BlockAsNxDomain\n            { get { return _blockAsNxDomain; } }\n\n            public List<DnsARecordData> ARecords\n            { get { return _aRecords; } }\n\n            public List<DnsAAAARecordData> AAAARecords\n            { get { return _aaaaRecords; } }","sourceCodeStart":779,"sourceCodeEnd":815,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/Apps/AdvancedBlockingApp/App.cs#L779-L815","documentation":"Thrown by the AdvancedBlockingApp UrlEntry constructor when building the per-URL list. The code switches on jsonUrl.ValueKind and only accepts String (a bare URL string) and Object (a URL object with url/blockAsNxDomain/blockingAddresses). Any other JSON value kind hits the default branch and raises InvalidDataException. This indicates a structurally malformed block/allow list entry in the config.","triggerScenarios":"A URL list entry that is a JSON number, array, boolean, or null instead of a string or object, e.g. '\"blockLists\": [ 12345 ]' or '\"blockLists\": [ [\"http://x/y\"] ]'. Passing a quoted-but-empty or wrong-typed element triggers it.","commonSituations":"Hand-editing the block list array and dropping the quotes around a URL, wrapping a URL in extra brackets, or pasting a numeric flag where a URL was expected; corrupt config import.","solutions":["Inspect the block/allow/regex/adblock list arrays in dnsApp.config and make every entry either a quoted URL string or a {\"url\": \"...\"} object.","Run the JSON through a linter/validator to locate the non-string/non-object element; the ValueKind reported (Number/Array/etc.) identifies the mistake.","Regenerate the list entry from the web UI to guarantee the correct shape."],"exampleFix":"// before (dnsApp.config)\n\"blockLists\": [ https://example.com/list.txt ]\n// after\n\"blockLists\": [ \"https://example.com/list.txt\" ]","handlingStrategy":"type-guard","validationCode":"foreach (JsonElement urlEntry in blockListsArray.EnumerateArray())\n{\n    if (urlEntry.ValueKind != JsonValueKind.String && urlEntry.ValueKind != JsonValueKind.Object)\n        throw new FormatException($\"Block list entry must be a URL string or a {{\\\"url\\\":...}} object, got {urlEntry.ValueKind}.\");\n}","typeGuard":"static bool IsValidUrlEntry(JsonElement e) => e.ValueKind == JsonValueKind.String || e.ValueKind == JsonValueKind.Object;","tryCatchPattern":null,"preventionTips":["Quote every URL string in the JSON arrays.","Prefer the {\"url\":\"...\"} object form when overriding blockAsNxDomain/blockingAddresses.","Lint the JSON config to catch unquoted or wrongly-typed array elements."],"tags":["csharp","config","json","schema","technitium","advanced-blocking-app"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}