{"record":{"id":"40d235f87272078d","repo":"tui-cs/Terminal.Gui","slug":"expected-a-valid-text-style-value","errorCode":null,"errorMessage":"Expected a valid text style value.","messagePattern":"Expected a valid text style value\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/AttributeJsonConverter.cs","lineNumber":93,"sourceCode":"\n                        break;\n                    case \"background\":\n                        background = JsonSerializer.Deserialize (ref reader, TuiSerializerContext.Instance.Color);\n\n                        break;\n                    case \"style\":\n                        if (reader.TokenType != JsonTokenType.String)\n                        {\n                            throw new JsonException ($\"{propertyName}: Expected a string value.\");\n                        }\n\n                        try\n                        {\n                            style = Enum.Parse<TextStyle> (reader.GetString ()!, ignoreCase: true);\n                        }\n                        catch (ArgumentException ex)\n                        {\n                            throw new JsonException (\"Expected a valid text style value.\", ex);\n                        }\n\n                        break;\n\n                    default:\n                        throw new JsonException ($\"{propertyName}: Unknown Attribute property .\");\n                }\n            }\n            catch (JsonException ex)\n            {\n                throw new JsonException ($\"{propertyName}: \\\"{property}\\\" - {ex.Message}\");\n            }\n        }\n\n        throw new JsonException ($\"{propertyName}: Bad Attribute.\");\n    }\n\n    public override void Write (Utf8JsonWriter writer, Attribute value, JsonSerializerOptions options)","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/AttributeJsonConverter.cs#L75-L111","documentation":"Thrown by AttributeJsonConverter.Read after Enum.Parse<TextStyle> raised ArgumentException because the Style string did not match any TextStyle enum member (case-insensitive). Inner exception is the original ArgumentException. The wrapper message is fixed text (the propertyName context is added by the outer catch at line 104).","triggerScenarios":"A config Attribute has a Style value like \"Bold2\", \"Heavy\", \"Struck\" — any string that is not a valid TextStyle member.","commonSituations":"Typo in a hand-edited config; using a style name from another library (e.g. CSS font-weight words) instead of Terminal.Gui's TextStyle names; version mismatch where a TextStyle member was renamed or removed.","solutions":["Check the TextStyle enum members for your Terminal.Gui version and use an exact name (e.g. Bold, Italic, Underline, Strikethrough, None).","If combining styles, use the format the Enum.Parse call accepts (comma-separated names for [Flags] enums).","Update the config to a known TextStyle name and reload."],"exampleFix":"// before\n\"Style\": \"Heavvy\"\n// after\n\"Style\": \"Bold\"","handlingStrategy":"validation","validationCode":"// Pre-validate that the Style string is a real TextStyle member.\nstring styleStr = attr.GetProperty (\"Style\").GetString ()!;\nif (!Enum.TryParse<TextStyle> (styleStr, ignoreCase: true, out _))\n    throw new ArgumentOutOfRangeException (nameof (styleStr), $\"Unknown TextStyle: {styleStr}\");","typeGuard":"static bool IsValidTextStyle (string s) => Enum.TryParse<TextStyle> (s, ignoreCase: true, out _);","tryCatchPattern":"try { ConfigurationManager.Apply (); }\ncatch (JsonException ex) when (ex.Message.Contains (\"valid text style value\"))\n{ /* replace the bad style name */ }","preventionTips":["Pin your config to the TextStyle members of the Terminal.Gui version you ship.","Cross-check style names against the TextStyle enum when upgrading."],"tags":["configuration","json","theming","attribute","textstyle","enum"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}