{"record":{"id":"a01927fceac8ccea","repo":"Flow-Launcher/Flow.Launcher","slug":"doublepinyinschema-schemakey-is-invalid-or-dou","errorCode":null,"errorMessage":"DoublePinyinSchema '{schemaKey}' is invalid or double pinyin table is broken.","messagePattern":"DoublePinyinSchema '(.+?)' is invalid or double pinyin table is broken\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Flow.Launcher.Infrastructure/PinyinAlphabet.cs","lineNumber":61,"sourceCode":"                }\n            };\n        }\n\n        public void Reload()\n        {\n            LoadDoublePinyinTable();\n            _pinyinCache.Clear();\n        }\n\n        private void CreateDoublePinyinTableFromStream(Stream jsonStream)\n        {\n            var table = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(jsonStream) ??\n                throw new InvalidOperationException(\"Failed to deserialize double pinyin table: result is null\");\n\n            var schemaKey = _settings.DoublePinyinSchema.ToString();\n            if (!table.TryGetValue(schemaKey, out var schemaDict))\n            {\n                throw new ArgumentException($\"DoublePinyinSchema '{schemaKey}' is invalid or double pinyin table is broken.\");\n            }\n\n            currentDoublePinyinTable = new ReadOnlyDictionary<string, string>(schemaDict);\n        }\n\n        private void LoadDoublePinyinTable()\n        {\n            if (!_settings.UseDoublePinyin)\n            {\n                currentDoublePinyinTable = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>());\n                return;\n            }\n\n            var tablePath = Path.Combine(AppContext.BaseDirectory, \"Resources\", \"double_pinyin.json\");\n            try\n            {\n                using var fs = File.OpenRead(tablePath);\n                CreateDoublePinyinTableFromStream(fs);","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/Flow-Launcher/Flow.Launcher/blob/7fc63b07bbaa10a0f0b2601487913fcba9ed24b0/Flow.Launcher.Infrastructure/PinyinAlphabet.cs#L43-L79","documentation":"Thrown as ArgumentException when the deserialized table is a valid non-null Dictionary but does not contain a key matching _settings.DoublePinyinSchema.ToString(). The schema name (an enum value, e.g. a custom schema) must exist as a top-level key in double_pinyin.json or the table cannot be selected. Like error 10, this propagates uncaught from CreateDoublePinyinTableFromStream.","triggerScenarios":"User selected a DoublePinyinSchema enum value whose string name is not present as a key in double_pinyin.json; the enum was extended with a new schema but the resource file wasn't updated; the schema's ToString() casing doesn't match the JSON key; the table JSON was edited and a schema section deleted.","commonSituations":"Version skew: a newer build references a schema enum not in the shipped resource; user manually edited double_pinyin.json and removed a schema; a plugin/extension added a schema enum without providing its key mapping; enum renamed but JSON not migrated.","solutions":["Open Resources/double_pinyin.json and confirm there is a top-level key whose name matches the selected DoublePinyinSchema enum value's ToString().","Reset the DoublePinyinSchema setting to a known-supported schema (e.g. the default).","If you added a custom enum value, add a matching schema section to the JSON file.","Restore the resource file from the official install to rule out manual edits."],"exampleFix":"// before — hard fail on unknown schema\nif (!table.TryGetValue(schemaKey, out var schemaDict))\n    throw new ArgumentException($\"DoublePinyinSchema '{schemaKey}' is invalid...\");\n\n// after — fall back to first available schema and log\nif (!table.TryGetValue(schemaKey, out var schemaDict))\n{\n    Log.Warn(nameof(PinyinAlphabet), $\"Schema '{schemaKey}' not found; falling back\");\n    schemaDict = table.Values.FirstOrDefault() ?? new Dictionary<string,string>();\n}","handlingStrategy":"validation","validationCode":"var schemaKey = _settings.DoublePinyinSchema.ToString();\nusing var fs = File.OpenRead(tablePath);\nvar table = JsonSerializer.Deserialize<Dictionary<string,Dictionary<string,string>>>(fs);\nif (table is null || !table.ContainsKey(schemaKey))\n{ Log.Warn(...); currentDoublePinyinTable = Empty; return; }","typeGuard":"null","tryCatchPattern":"try { CreateDoublePinyinTableFromStream(fs); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"DoublePinyinSchema\"))\n{ Log.Exception(...); currentDoublePinyinTable = Empty; }","preventionTips":["When adding a new DoublePinyinSchema enum value, add its key mapping to the JSON resource in the same change.","Reset the schema setting to a known-supported value if errors appear after an update.","Keep schema key names consistent with the enum's ToString().","Validate the resource file is intact before relying on a custom schema."],"tags":["pinyin","json","config","validation"],"backgroundTag":null,"analyzedSha":"7fc63b07bbaa10a0f0b2601487913fcba9ed24b0","analyzedAt":"2026-08-13T14:54:20.914Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}