{"record":{"id":"1194e063ae107136","repo":"tui-cs/Terminal.Gui","slug":"propertyname-unexpected-key-property","errorCode":null,"errorMessage":"{propertyName}: Unexpected Key property.","messagePattern":"(.+?): Unexpected Key property\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/KeyCodeJsonConverter.cs","lineNumber":110,"sourceCode":"                                        modifiers.Add (modifierDict [mod]);\n                                    }\n                                    catch (KeyNotFoundException e)\n                                    {\n                                        throw new JsonException ($\"{propertyName}: \\\"{mod}\\\" is not a valid modifier.\", e);\n                                    }\n                                }\n                            }\n                            else\n                            {\n                                throw new JsonException (\n                                                         $\"{propertyName}: Expected an array of modifiers, but got \\\"{reader.TokenType}\\\".\"\n                                                        );\n                            }\n\n                            break;\n\n                        default:\n                            throw new JsonException ($\"{propertyName}: Unexpected Key property.\");\n                    }\n                }\n            }\n\n            foreach (KeyCode modifier in modifiers)\n            {\n                key |= modifier;\n            }\n\n            return key;\n        }\n\n        throw new JsonException ($\"{propertyName}: Unexpected StartObject token when parsing Key: {reader.TokenType}.\");\n    }\n\n    public override void Write (Utf8JsonWriter writer, KeyCode value, JsonSerializerOptions options)\n    {\n        writer.WriteStartObject ();","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/KeyCodeJsonConverter.cs#L92-L128","documentation":"Thrown by KeyCodeJsonConverter.Read (KeyCodeJsonConverter.cs:109-110) via the default switch case when a property name inside a Key JSON object is neither \"key\" nor \"modifiers\" (compared case-insensitively after ToLowerInvariant). Any unrecognized property in the Key object is rejected.","triggerScenarios":"A keybinding JSON object contains an extra/unknown property, e.g. {\"Key\":\"A\",\"Modifiers\":[\"Ctrl\"],\"Scancode\":65} or {\"Key\":\"A\",\"Char\":\"a\"}. The 'default' branch fires for the unrecognized property name.","commonSituations":"User adds a property (Scancode, Char, CharKey, VirtualKey) thinking the converter supports it. Config schema drift across versions where a property was renamed. Copy-paste from documentation of a different key-serialization format.","solutions":["Remove the unrecognized property; Key objects only support \"Key\" and \"Modifiers\".","Check the property name spelling and case — matching is case-insensitive but the names must be 'key' or 'modifiers'.","If you need to express additional key metadata, use the Key[] string-array format with Key.TryParse-compatible strings.","Regenerate the config from Terminal.Gui to see the exact supported shape."],"exampleFix":"// before\n{ \"Key\": \"A\", \"Modifiers\": [\"Ctrl\"], \"Scancode\": 30 }\n\n// after\n{ \"Key\": \"A\", \"Modifiers\": [\"Ctrl\"] }","handlingStrategy":"validation","validationCode":"using System.Collections.Generic;\n\nstatic readonly HashSet<string> AllowedKeyProps = new (System.StringComparer.OrdinalIgnoreCase)\n{ \"Key\", \"Modifiers\" };\n\nstatic bool KeyObjectHasOnlyAllowedProps (IEnumerable<string> propNames)\n    => propNames.All (p => AllowedKeyProps.Contains (p));\n\n// Validate the Key object schema before serializing/deserializing.","typeGuard":"static bool IsAllowedKeyProperty (string propName)\n    => propName.Equals (\"Key\", StringComparison.OrdinalIgnoreCase)\n       || propName.Equals (\"Modifiers\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try\n{\n    ConfigurationManager.Load (configJson);\n}\ncatch (JsonException ex) when (ex.Message.Contains (\"Unexpected Key property\"))\n{\n    // The Key object has an unknown property. Remove it and reload.\n}","preventionTips":["Only include \"Key\" and \"Modifiers\" in Key JSON objects.","Remove any extra metadata properties (Scancode, Char, VirtualKey).","Regenerate config from Terminal.Gui to confirm the supported shape.","Validate the Key object schema before loading config."],"tags":["json","configuration","keybindings","key","schema","serialization"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}