{"record":{"id":"8a722068c1394b75","repo":"SubtitleEdit/subtitleedit","slug":"namelist-unable-to-read-name-list-file-filename","errorCode":null,"errorMessage":"NameList: Unable to read name list file: {fileNameOrUrl}","messagePattern":"NameList: Unable to read name list file: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"src/libse/Dictionaries/NameList.cs","lineNumber":181,"sourceCode":"                                    {\n                                        if (reader.Name == \"name\")\n                                        {\n                                            var name = reader.ReadElementContentAsString().Trim();\n                                            if (name.Length > 0)\n                                            {\n                                                _blackList.Add(name);\n                                            }\n                                        }\n                                    }\n                                }\n                            }\n                        }\n                    }\n                }\n            }\n            catch (Exception ex)\n            {\n                throw new Exception(\"NameList: Unable to read name list file: \" + fileNameOrUrl, ex);\n            }\n        }\n\n        public bool Remove(string name)\n        {\n            name = name.Trim();\n            if (name.Length > 1 && _namesList.Contains(name) || _namesMultiList.Contains(name))\n            {\n                // Try removing name from both lists\n                _namesList.Remove(name);\n                _namesMultiList.Remove(name);\n                _namesMultiListParts = null;\n\n                var fileName = GetLocalNamesUserFileName();\n                var nameListXml = CreateDocument(fileName);\n\n                // Add removed name to blacklist\n                var nameNode = nameListXml.CreateElement(\"name\");","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libse/Dictionaries/NameList.cs#L163-L199","documentation":"NameList's loader wraps the entire name-list-file parse (XML fetch, HTTP/HTTPS download, or local file read) in a try/catch and rethrows as a generic Exception with the file name or URL. It signals that the names resource could not be obtained or parsed for a given language, breaking spell-check/name-detection features that depend on it.","triggerScenarios":"Network failure fetching a remote names XML; HTTP 404/403 for the names URL; malformed XML (unexpected root, missing elements); local file missing or unreadable; encoding mismatch causing the reader to throw.","commonSituations":"Offline machine trying to fetch remote name lists; outdated URL after a server reorganization; proxy/firewall blocking the request; corrupt local names.xml; locale for which no names file exists.","solutions":["Ship a local fallback names file and only fetch remote updates opportunistically.","Catch the exception and degrade gracefully (disable name-based features instead of crashing spell-check).","Verify the URL/file path is reachable (HEAD request / File.Exists) before parsing.","Wrap the XML reader in a schema-tolerant parse and skip malformed entries."],"exampleFix":"// before\ncatch (Exception ex) { throw new Exception(\"NameList: Unable to read name list file: \" + fileNameOrUrl, ex); }\n\n// after\ncatch (Exception ex)\n{\n    Logger.Warn(ex, $\"NameList: failed to load {fileNameOrUrl}; falling back to built-in names.\");\n    LoadBuiltinFallback();\n}","handlingStrategy":"fallback","validationCode":"if (string.IsNullOrEmpty(fileNameOrUrl)) throw new ArgumentException(\"name list path required\");\nif (Uri.IsWellFormedUriString(fileNameOrUrl, UriKind.Absolute)) { /* HEAD-check reachable */ }\nelse if (!File.Exists(fileNameOrUrl)) { /* use built-in fallback */ }","typeGuard":null,"tryCatchPattern":"try { names = new NameList(fileNameOrUrl); }\ncatch (Exception ex) when (ex.Message.Contains(\"name list file\")) { names = NameList.BuiltIn; }","preventionTips":["Ship a built-in names list as a fallback.","Verify URL reachability / file existence before loading.","Log and degrade rather than crash spell-check."],"tags":["names","dictionary","network","xml","subtitle","fallback"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}