tui-cs/Terminal.Gui · error · JsonException

{propertyName}: Unrecognized Scheme Attribute name.

Error message

{propertyName}: Unrecognized Scheme Attribute name.

What it means

A property name inside a Scheme object does not match any known VisualRole (matched case-insensitively). The converter accepts a fixed set: Normal, HotNormal, Focus, HotFocus, Active, HotActive, Highlight, Editable, ReadOnly, Disabled, and the Code* roles. Any other name is rejected.

Source

Thrown at Terminal.Gui/Configuration/SchemeJsonConverter.cs:70

                    "hotactive" => scheme with { HotActive = attribute },
                    "highlight" => scheme with { Highlight = attribute },
                    "editable" => scheme with { Editable = attribute },
                    "readonly" => scheme with { ReadOnly = attribute },
                    "disabled" => scheme with { Disabled = attribute },
                    "code" => scheme with { Code = attribute },
                    "codecomment" => scheme with { CodeComment = attribute },
                    "codekeyword" => scheme with { CodeKeyword = attribute },
                    "codestring" => scheme with { CodeString = attribute },
                    "codenumber" => scheme with { CodeNumber = attribute },
                    "codeoperator" => scheme with { CodeOperator = attribute },
                    "codetype" => scheme with { CodeType = attribute },
                    "codepreprocessor" => scheme with { CodePreprocessor = attribute },
                    "codeidentifier" => scheme with { CodeIdentifier = attribute },
                    "codeconstant" => scheme with { CodeConstant = attribute },
                    "codepunctuation" => scheme with { CodePunctuation = attribute },
                    "codefunctionname" => scheme with { CodeFunctionName = attribute },
                    "codeattribute" => scheme with { CodeAttribute = attribute },
                    _ => throw new JsonException ($"{propertyName}: Unrecognized Scheme Attribute name.")
                };
            }
            else
            {
                throw new JsonException ("null property name.");
            }
        }

        throw new JsonException ($"After {propertyName}: Invalid Json.");
    }

    /// <inheritdoc/>
    public override void Write (Utf8JsonWriter writer, Scheme value, JsonSerializerOptions options)
    {
        writer.WriteStartObject ();

        foreach (VisualRole role in Enum.GetValues<VisualRole> ())
        {

View on GitHub (pinned to 2e47b11478)

Solutions

  1. Use a valid VisualRole name (see the VisualRole enum and the switch arms in SchemeJsonConverter).
  2. Check the current version's VisualRole enum for the exact spelling.
  3. Remove the unrecognized role entry.

Example fix

// before
{ "Normla": {"Foreground":"White"} }
// after
{ "Normal": {"Foreground":"White"} }
Defensive patterns

Strategy: validation

Validate before calling

static readonly HashSet<string> ValidRoles =
    new (Enum.GetNames<VisualRole> (), StringComparer.OrdinalIgnoreCase);

static bool IsValidRole (string name) => ValidRoles.Contains (name);

Try / catch

try { ConfigurationManager.Apply (); }
catch (JsonException ex) when (ex.Message.Contains ("Unrecognized Scheme Attribute name"))
{ /* ex.Message names the bad role */ }

Prevention

When it happens

Trigger: A typo like "Normla", an outdated role name from a previous version, or a non-role name (e.g. "Background", "Selected").

Common situations: Upgrading Terminal.Gui across versions where role names changed; copying a role name from outdated docs; plain typos.

Related errors


AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13). Data as JSON: /api/errors/68c9ea95a076c358. Report an issue: GitHub.