{"record":{"id":"840ff973bacaea66","repo":"TechnitiumSoftware/DnsServer","slug":"invalid-adguard-upstreams-config-file-format-miss","errorCode":null,"errorMessage":"Invalid AdGuard Upstreams config file format: missing ']' bracket.","messagePattern":"Invalid AdGuard Upstreams config file format: missing '\\]' bracket\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"Apps/AdvancedForwardingApp/App.cs","lineNumber":647,"sourceCode":"                        while (true)\n                        {\n                            line = sR.ReadLine();\n                            if (line is null)\n                                break; //eof\n\n                            line = line.TrimStart();\n\n                            if (line.Length == 0)\n                                continue; //skip empty line\n\n                            if (line.StartsWith('#'))\n                                continue; //skip comment line\n\n                            if (line.StartsWith('['))\n                            {\n                                int i = line.LastIndexOf(']');\n                                if (i < 0)\n                                    throw new FormatException(\"Invalid AdGuard Upstreams config file format: missing ']' bracket.\");\n\n                                string[] domains = line.Substring(1, i - 1).Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);\n                                string forwarder = line.Substring(i + 1);\n\n                                if (forwarder == \"#\")\n                                {\n                                    if (defaultForwarderRecords.Count == 0)\n                                        throw new FormatException(\"Invalid AdGuard Upstreams config file format: missing default upstream servers.\");\n\n                                    forwardings.Add(new Forwarding(defaultForwarderRecords, domains));\n                                }\n                                else\n                                {\n                                    List<DnsForwarderRecordData> forwarderRecords = new List<DnsForwarderRecordData>();\n                                    string word = PopWord(ref forwarder);\n\n                                    while (word.Length > 0)\n                                    {","sourceCodeStart":629,"sourceCodeEnd":665,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/Apps/AdvancedForwardingApp/App.cs#L629-L665","documentation":"Thrown while parsing an AdGuard Upstreams config file (a separate upstream-format file, not the app JSON config) imported by the AdvancedForwardingApp. A line starting with '[' must contain a matching ']' that delimits the domain list from the upstream server(s). If no ']' is found (LastIndexOf returns -1), the file is rejected with FormatException.","triggerScenarios":"An AdGuard upstreams line beginning with '[' but missing the closing ']', e.g. '[/example.com/ 1.1.1.1' or '[]example.com 8.8.8.8' written incorrectly. Any '['-prefixed line without a ']' triggers it.","commonSituations":"Hand-editing an AdGuard-style upstreams file and dropping the ']' bracket; truncated line from a copy-paste; wrong file format chosen for the upstream source.","solutions":["Open the referenced AdGuard upstreams file and add the missing ']' bracket on the indicated line, using the syntax [/domain1/domain2/] upstream1 upstream2.","Re-download or re-export the upstreams file from a known-good AdGuard source to restore correct formatting.","Validate every '['-prefixed line ends its domain section with ']' before the upstream servers."],"exampleFix":"// before (upstreams file)\n[/example.com/ 1.1.1.1\n// after\n[/example.com/] 1.1.1.1","handlingStrategy":"validation","validationCode":"// Validate each '['-prefixed line of an AdGuard upstreams file has a matching ']'.\nforeach (string line in File.ReadAllLines(upstreamsPath))\n{\n    string t = line.TrimStart();\n    if (t.StartsWith('[') && t.LastIndexOf(']') < 0)\n        throw new FormatException($\"AdGuard upstreams line missing ']': {line}\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-export upstreams files from a known-good AdGuard source.","Lint '['-prefixed lines to confirm a ']' before the upstream server tokens.","Prefer the app's native JSON forwarders config over hand-edited AdGuard files."],"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"}