{"record":{"id":"a8c7fc42eee07eef","repo":"TechnitiumSoftware/DnsServer","slug":"invalid-adguard-upstreams-config-file-format-miss-a8c7fc","errorCode":null,"errorMessage":"Invalid AdGuard Upstreams config file format: missing upstream servers.","messagePattern":"Invalid AdGuard Upstreams config file format: missing upstream servers\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"Apps/AdvancedForwardingApp/App.cs","lineNumber":680,"sourceCode":"                                    string word = PopWord(ref forwarder);\n\n                                    while (word.Length > 0)\n                                    {\n                                        string nextWord = PopWord(ref forwarder);\n\n                                        if (nextWord.StartsWith('('))\n                                        {\n                                            word += \" \" + nextWord;\n                                            nextWord = PopWord(ref forwarder);\n                                        }\n\n                                        forwarderRecords.Add(GetForwarderRecord(NameServerAddress.Parse(word), _dnssecValidation, _configProxyServer));\n\n                                        word = nextWord;\n                                    }\n\n                                    if (forwarderRecords.Count == 0)\n                                        throw new FormatException(\"Invalid AdGuard Upstreams config file format: missing upstream servers.\");\n\n                                    forwardings.Add(new Forwarding(forwarderRecords, domains));\n                                }\n                            }\n                            else\n                            {\n                                defaultForwarderRecords.Add(GetForwarderRecord(NameServerAddress.Parse(line), _dnssecValidation, _configProxyServer));\n                            }\n                        }\n\n                        _configFileLastModified = File.GetLastWriteTimeUtc(fS.SafeFileHandle);\n                    }\n\n                    _defaultForwarderRecords = defaultForwarderRecords;\n                    _forwardings = forwardings;\n\n                    _dnsServer.WriteLog(\"The app has successfully loaded AdGuard Upstreams config file: \" + _configFile);\n                }","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/Apps/AdvancedForwardingApp/App.cs#L662-L698","documentation":"Thrown while parsing an AdGuard Upstreams file when a domain-scoped line declares an explicit upstream server list after the ']' bracket but none could be parsed (the forwarderRecords list stayed empty after consuming the line). FormatException is raised.","triggerScenarios":"An AdGuard upstreams line like '[/example.com/]' with no server tokens after the bracket, or whose post-bracket text is only whitespace/parentheses, leaving zero upstream records.","commonSituations":"Trailing whitespace after ']' with no server; malformed parenthesis grouping consumed by PopWord but yielding no server; copy-paste that dropped the server name.","solutions":["Add one or more valid upstream servers after the ']' on that line, e.g. '[/example.com/] tls://1.1.1.1'.","Ensure each server token is a value NameServerAddress.Parse can accept (IP, DoH/DoT URL).","If the domain should use the default upstream, use '#' instead of leaving it blank."],"exampleFix":"// before (upstreams file)\n[/example.com/]\n// after\n[/example.com/] https://dns.google/dns-query","handlingStrategy":"validation","validationCode":"foreach (string line in File.ReadAllLines(upstreamsPath))\n{\n    string t = line.TrimStart();\n    if (t.StartsWith('['))\n    {\n        int i = t.LastIndexOf(']');\n        if (i >= 0 && t.Substring(i + 1).Trim() == string.Empty)\n            throw new FormatException($\"AdGuard upstreams line has no server after ']': {line}\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always put at least one upstream server token after the ']' bracket.","Use '#' only when a default upstream is defined.","Lint upstreams files for empty post-bracket server lists."],"tags":["csharp","config","adguard","format","technitium","advanced-forwarding-app"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}