tui-cs/Terminal.Gui · error · JsonException
Invalid TraceCategory value in array: '{value}'
Error message
Invalid TraceCategory value in array: '{value}' What it means
Thrown by TraceCategoryJsonConverter.Read while parsing the array form when an element IS a string but Enum.TryParse fails to map it to a TraceCategory member (case-insensitive). This is the per-element analog of error 90: at least one name in the array is invalid.
Source
Thrown at Terminal.Gui/Configuration/TraceCategoryJsonConverter.cs:57
{
if (reader.TokenType == JsonTokenType.EndArray)
{
break;
}
if (reader.TokenType != JsonTokenType.String)
{
throw new JsonException ($"Unexpected token type in TraceCategory array: {reader.TokenType}");
}
string value = reader.GetString ()!;
if (Enum.TryParse (value, true, out TraceCategory category))
{
result |= category;
}
else
{
throw new JsonException ($"Invalid TraceCategory value in array: '{value}'");
}
}
return result;
}
throw new JsonException ($"Unexpected token type for TraceCategory: {reader.TokenType}");
}
public override void Write (Utf8JsonWriter writer, TraceCategory value, JsonSerializerOptions options)
{
if (value == TraceCategory.None)
{
writer.WriteStringValue ("None");
return;
}
View on GitHub (pinned to 2e47b11478)
Solutions
- Correct the offending element to a valid TraceCategory member name (the error message echoes the bad value in quotes).
- Check the current TraceCategory enum definition for the available names.
- Drop the invalid element entirely if it's no longer relevant.
Example fix
// before "TraceCategory": ["Command", "Mose"] // after "TraceCategory": ["Command", "Mouse"]
Defensive patterns
Strategy: validation
Validate before calling
bool AllValidNames (JsonElement el)
=> el.EnumerateArray ().All (e => e.ValueKind == JsonValueKind.String && Enum.TryParse<TraceCategory> (e.GetString (), true, out _)); Type guard
static bool IsValidTraceCategory (string value) => Enum.TryParse<TraceCategory> (value, true, out _);
Try / catch
ConfigurationManager.ThrowOnJsonErrors = false;
Prevention
- Spell-check each TraceCategory name against the enum definition.
- Drop unknown names rather than leaving them in config.
- Regenerate config snippets from the enum to avoid stale names after upgrades.
When it happens
Trigger: A TraceCategory array containing a typo or unknown name, e.g. ["Command","Mose"] or ["Command","Drawing"] when Drawing isn't a member.
Common situations: Misspelling one element of a multi-category list; referencing a category removed/renamed in a newer Terminal.Gui version.
Related errors
- Invalid TraceCategory value: '{value}'
- Unexpected token type in TraceCategory array: {reader.TokenT
- Unexpected token type for TraceCategory: {reader.TokenType}
- Unexpected StartObject token when parsing Attribute: {reader
- {propertyName}: Both Foreground and Background colors must b
AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13).
Data as JSON: /api/errors/6efb1e8f5c5382df.
Report an issue: GitHub.