{"record":{"id":"54c0ea0d5404856e","repo":"litedb-org/LiteDB","slug":"0-54c0ea","errorCode":"0","errorMessage":"Invalid culture name","messagePattern":"Invalid culture name","errorType":"exception","errorClass":"LiteException","httpStatus":null,"severity":"error","filePath":"LiteDB/Utils/LCID.cs","lineNumber":471,"sourceCode":"                return new CultureInfo(name);\n            }\n            else\n            {\n                throw new ArgumentException(\"Invalid LCID code\");\n            }\n        }\n\n        public static int GetLCID(string culture)\n        {\n            foreach(var item in _mappings)\n            {\n                if (item.Value == culture)\n                {\n                    return item.Key;\n                }\n            }\n\n            throw new LiteException(0, $\"Invalid culture name\");\n        }\n\n        /// <summary>\n        /// Get current system operation LCID culture\n        /// </summary>\n        public static int Current\n        {\n            get\n            {\n                var current = CultureInfo.CurrentCulture.Name;\n\n                var lcid = _mappings.FirstOrDefault(x => x.Value == current);\n\n                // for 4096 culture LCID, returns 127 (invariant culture)\n                if (lcid.Key == 0)\n                {\n                    return 127;\n                }","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/litedb-org/LiteDB/blob/f906a5f850678719e39a39a006cb66dcae563cfa/LiteDB/Utils/LCID.cs#L453-L489","documentation":"Thrown by LCID.GetLCID(string culture) when the supplied culture name (e.g. 'en-US') is not found by reverse lookup in the _mappings dictionary. It performs a linear search of values and throws LiteException if none matches. Only cultures explicitly listed in the table resolve.","triggerScenarios":"Calling LCID.GetLCID with a culture name absent from the built-in table; passing a custom/neutral/mis-cased name (lookup is case-/exact-sensitive: 'en-us' won't match 'en-US'); reading a collation name not in this build.","commonSituations":"Mismatched casing or region suffix; locale names produced by a different runtime than the table; indexes referencing a collation whose name isn't mapped; version skew in the LCID table.","solutions":["Pass the exact culture string as listed in the LCID table (correct case and region suffix).","Validate/fall back: try CultureInfo.GetCultureInfo(name) and resolve its LCID via the framework instead.","Normalize the name (canonicalize case) before lookup.","Re-create the index with a supported collation name."],"exampleFix":"// before\nvar id = LCID.GetLCID(\"en-us\"); // case mismatch -> throws\n\n// after\nvar id = LCID.GetLCID(CultureInfo.GetCultureInfo(\"en-us\").Name); // 'en-US'","handlingStrategy":"validation","validationCode":"// canonicalize via the framework first, then look up\nvar name = CultureInfo.GetCultureInfo(culture).Name; // normalizes case/region\nint lcid = LCID.GetLCID(name);","typeGuard":null,"tryCatchPattern":"try { int id = LCID.GetLCID(culture); }\ncatch (LiteException ex) when (ex.Message.Contains(\"Invalid culture name\")) {\n    // normalize/validate the name, or fall back to invariant\n}","preventionTips":["Canonicalize culture names (correct case/region) before lookup.","Use CultureInfo.GetCultureInfo to validate names upstream.","Match index collation names to entries in the LCID table."],"tags":["locale","collation","validation","lookup"],"backgroundTag":null,"analyzedSha":"f906a5f850678719e39a39a006cb66dcae563cfa","analyzedAt":"2026-08-13T21:56:30.148Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}