{"record":{"id":"9a718aaab0058db9","repo":"tui-cs/Terminal.Gui","slug":"propertyname-bad-attribute","errorCode":null,"errorMessage":"{propertyName}: Bad Attribute.","messagePattern":"(.+?): Bad Attribute\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/AttributeJsonConverter.cs","lineNumber":108,"sourceCode":"                        }\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)\n    {\n        writer.WriteStartObject ();\n        writer.WritePropertyName (nameof (Attribute.Foreground));\n        ColorJsonConverter.Instance.Write (writer, value.Foreground, options);\n        writer.WritePropertyName (nameof (Attribute.Background));\n        ColorJsonConverter.Instance.Write (writer, value.Background, options);\n        if (value.Style != TextStyle.None)\n        {\n            writer.WritePropertyName (nameof (Attribute.Style));\n            writer.WriteStringValue (value.Style.ToString ());\n        }\n\n        writer.WriteEndObject ();\n    }\n}","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/AttributeJsonConverter.cs#L90-L126","documentation":"Thrown at the end of AttributeJsonConverter.Read if the reader loop exits without ever hitting an EndObject token — i.e. the JSON stream ended mid-Attribute (truncated input). The loop `while (reader.Read())` terminates because there are no more tokens, so the object was never closed.","triggerScenarios":"Truncated config JSON (file cut off, network stream ended early, StringBuilder incomplete). The Attribute object has no closing brace and the reader runs out of tokens.","commonSituations":"A config file was partially written (interrupted save); a manually pasted JSON fragment missing the closing `}`; a templating system that dropped the tail.","solutions":["Round-trip the JSON through a parser (System.Text.Json.JsonDocument.Parse) before handing it to ConfigurationManager to confirm it is complete and well-formed.","Open the file and confirm every `{` has a matching `}`.","Regenerate the config from a known-good source."],"exampleFix":"// before (truncated)\n{ \"Foreground\": \"Red\", \"Background\": \"Black\"\n// after\n{ \"Foreground\": \"Red\", \"Background\": \"Black\" }","handlingStrategy":"validation","validationCode":"// Reject truncated JSON up front.\nusing var doc = JsonDocument.Parse (jsonString); // throws JsonException if truncated\n// If you also want to assert the Attribute object closed:\nif (doc.RootElement.TryGetProperty (\"SomeAttr\", out var a)\n    && a.ValueKind != JsonValueKind.Object)\n    throw new FormatException (\"Attribute is not a complete JSON object.\");","typeGuard":null,"tryCatchPattern":"try { ConfigurationManager.Apply (); }\ncatch (JsonException ex) when (ex.Message.EndsWith (\"Bad Attribute.\"))\n{ /* config is truncated; re-fetch/re-save the file */ }","preventionTips":["Always JsonDocument.Parse config before Load to catch truncation.","Write config files atomically (temp file + rename) to avoid partial writes."],"tags":["configuration","json","theming","attribute","truncated"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}