TechnitiumSoftware/DnsServer · error · InvalidDataException
Unexpected URL format: {jsonUrl.ValueKind}
Error message
Unexpected URL format: {jsonUrl.ValueKind} What it means
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.
Source
Thrown at Apps/AdvancedBlockingApp/App.cs:797
aaaaRecords.Add(new DnsAAAARecordData(address));
break;
}
}
}
_aRecords = aRecords.Count > 0 ? aRecords : group.ARecords;
_aaaaRecords = aaaaRecords.Count > 0 ? aaaaRecords : group.AAAARecords;
}
else
{
_aRecords = group.ARecords;
_aaaaRecords = group.AAAARecords;
}
break;
default:
throw new InvalidDataException("Unexpected URL format: " + jsonUrl.ValueKind);
}
}
#endregion
#region properties
public Uri? Uri
{ get { return _uri; } }
public bool BlockAsNxDomain
{ get { return _blockAsNxDomain; } }
public List<DnsARecordData> ARecords
{ get { return _aRecords; } }
public List<DnsAAAARecordData> AAAARecords
{ get { return _aaaaRecords; } }View on GitHub (pinned to d0484b6c1e)
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.
Example fix
// before (dnsApp.config) "blockLists": [ https://example.com/list.txt ] // after "blockLists": [ "https://example.com/list.txt" ]
Defensive patterns
Strategy: type-guard
Validate before calling
foreach (JsonElement urlEntry in blockListsArray.EnumerateArray())
{
if (urlEntry.ValueKind != JsonValueKind.String && urlEntry.ValueKind != JsonValueKind.Object)
throw new FormatException($"Block list entry must be a URL string or a {{\"url\":...}} object, got {urlEntry.ValueKind}.");
} Type guard
static bool IsValidUrlEntry(JsonElement e) => e.ValueKind == JsonValueKind.String || e.ValueKind == JsonValueKind.Object;
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Local end point group map contains an invalid end point: {lo
- Network group map contains an invalid network address: {netw
- Groups array was not defined.
- Forwarder was not defined: {forwarderName}
- No 'forwarderAddresses' were configured.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/2ed363524a4a24b5.
Report an issue: GitHub.