{"record":{"id":"e93ad7705b5daf13","repo":"tui-cs/Terminal.Gui","slug":"after-propertyname-expected-attribute-but-got","errorCode":null,"errorMessage":"After {propertyName}: Expected Attribute but got {attrObj?.GetType ().Name ?? \"null\"} when parsing Scheme.","messagePattern":"After (.+?): Expected Attribute but got (.+?) when parsing Scheme\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/SchemeJsonConverter.cs","lineNumber":41,"sourceCode":"            if (reader.TokenType == JsonTokenType.EndObject)\n            {\n                return scheme;\n            }\n\n            if (reader.TokenType != JsonTokenType.PropertyName)\n            {\n                throw new JsonException ($\"After {propertyName}: Expected PropertyName but got another token when parsing Attribute: {reader.TokenType}.\");\n            }\n\n            propertyName = reader.GetString ();\n            reader.Read ();\n\n            // Make sure attributes are marked as explicitly set when deserialized\n            object? attrObj = JsonSerializer.Deserialize (ref reader, TuiSerializerContext.Instance.Attribute);\n\n            if (attrObj is not Attribute attribute)\n            {\n                throw new JsonException ($\"After {propertyName}: Expected Attribute but got {attrObj?.GetType ().Name ?? \"null\"} when parsing Scheme.\");\n            }\n            if (propertyName is { })\n            {\n                scheme = propertyName.ToLowerInvariant () switch\n                {\n                    \"normal\" => scheme with { Normal = attribute },\n                    \"hotnormal\" => scheme with { HotNormal = attribute },\n                    \"focus\" => scheme with { Focus = attribute },\n                    \"hotfocus\" => scheme with { HotFocus = attribute },\n                    \"active\" => scheme with { Active = attribute },\n                    \"hotactive\" => scheme with { HotActive = attribute },\n                    \"highlight\" => scheme with { Highlight = attribute },\n                    \"editable\" => scheme with { Editable = attribute },\n                    \"readonly\" => scheme with { ReadOnly = attribute },\n                    \"disabled\" => scheme with { Disabled = attribute },\n                    \"code\" => scheme with { Code = attribute },\n                    \"codecomment\" => scheme with { CodeComment = attribute },\n                    \"codekeyword\" => scheme with { CodeKeyword = attribute },","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/SchemeJsonConverter.cs#L23-L59","documentation":"A Scheme property's value was read by the Attribute deserializer (TuiSerializerContext.Attribute), but the result is not an Attribute — typically because the value was JSON null or structurally wrong for an Attribute, so the converter returned null or a different type.","triggerScenarios":"\"Normal\": null where an Attribute is required, or a value shape the AttributeJsonConverter cannot map (e.g. a bare string that is not a valid color).","commonSituations":"Setting a role to null in JSON; providing a malformed Attribute object missing required color fields.","solutions":["Provide a complete Attribute object with Foreground/Background (e.g. { \"Foreground\": \"White\", \"Background\": \"Blue\" }).","Remove the role entry entirely instead of setting it to null — the Scheme falls back to defaults."],"exampleFix":"// before\n\"Normal\": null\n// after\n\"Normal\": { \"Foreground\": \"White\", \"Background\": \"Blue\" }","handlingStrategy":"validation","validationCode":"using var doc = JsonDocument.Parse (configText);\n// For each Scheme role, assert the value is a non-null object with color fields\nforeach (JsonProperty role in schemeEl.EnumerateObject ())\n{\n    if (role.Value.ValueKind != JsonValueKind.Object) return false;\n}","typeGuard":null,"tryCatchPattern":"try { ConfigurationManager.Apply (); }\ncatch (JsonException ex) when (ex.Message.Contains (\"Expected Attribute\"))\n{ /* ex.Message names the role that failed */ }","preventionTips":["Never set a VisualRole to null in theme JSON.","Omit a role rather than null it; the Scheme falls back to defaults."],"tags":["config","json","scheme","attribute","theming"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}