tui-cs/Terminal.Gui · error · JsonException
{propertyName}: Unknown Attribute property .
Error message
{propertyName}: Unknown Attribute property . What it means
Thrown by the default case of AttributeJsonConverter.Read's switch: the JSON property name is not "foreground", "background", or "style" (compared case-insensitively). Attribute objects only accept those three keys. Note the trailing space + period in the message is a literal formatting quirk in the source.
Source
Thrown at Terminal.Gui/Configuration/AttributeJsonConverter.cs:99
case "style":
if (reader.TokenType != JsonTokenType.String)
{
throw new JsonException ($"{propertyName}: Expected a string value.");
}
try
{
style = Enum.Parse<TextStyle> (reader.GetString ()!, ignoreCase: true);
}
catch (ArgumentException ex)
{
throw new JsonException ("Expected a valid text style value.", ex);
}
break;
default:
throw new JsonException ($"{propertyName}: Unknown Attribute property .");
}
}
catch (JsonException ex)
{
throw new JsonException ($"{propertyName}: \"{property}\" - {ex.Message}");
}
}
throw new JsonException ($"{propertyName}: Bad Attribute.");
}
public override void Write (Utf8JsonWriter writer, Attribute value, JsonSerializerOptions options)
{
writer.WriteStartObject ();
writer.WritePropertyName (nameof (Attribute.Foreground));
ColorJsonConverter.Instance.Write (writer, value.Foreground, options);
writer.WritePropertyName (nameof (Attribute.Background));
ColorJsonConverter.Instance.Write (writer, value.Background, options);View on GitHub (pinned to 2e47b11478)
Solutions
- Rename the key to one of: Foreground, Background, Style (case-insensitive).
- Remove the unrecognized key if it is not needed.
- Check the AttributeJsonConverter.Write output to see the canonical key names the library itself emits.
Example fix
// before
{ "Fg": "Red", "Bg": "Black" }
// after
{ "Foreground": "Red", "Background": "Black" } Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> _attrKeys = new (StringComparer.OrdinalIgnoreCase) { "foreground", "background", "style" };
foreach (var p in attr.EnumerateObject ())
if (!_attrKeys.Contains (p.Name))
throw new InvalidOperationException ($"Unknown Attribute key: {p.Name}"); Type guard
static bool IsKnownAttributeKey (string key) =>
key.Equals ("foreground", StringComparison.OrdinalIgnoreCase)
|| key.Equals ("background", StringComparison.OrdinalIgnoreCase)
|| key.Equals ("style", StringComparison.OrdinalIgnoreCase); Try / catch
try { ConfigurationManager.Apply (); }
catch (JsonException ex) when (ex.Message.Contains ("Unknown Attribute property"))
{ /* remove/rename the unknown key */ } Prevention
- Keep an allow-list of Attribute keys in any config editor you ship.
- Serialize a sample Attribute to learn the canonical keys.
When it happens
Trigger: A config Attribute contains a key like "Color", "Fg", "Bg", "Text", "Width", or any unrecognized property.
Common situations: Using an abbreviation instead of the full name; carrying over a property name from v1 or another theming system; typo ("Forground").
Related errors
- {propertyName}: Unexpected token when parsing Attribute: {re
- {propertyName}: Expected a string value.
- Expected a valid text style value.
- {propertyName}: "{property}" - {ex.Message}
- {propertyName}: Bad Attribute.
AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13).
Data as JSON: /api/errors/369693535b29c709.
Report an issue: GitHub.