tui-cs/Terminal.Gui · error · JsonException

null property name.

Error message

null property name.

What it means

reader.GetString() returned null for a property name inside a Scheme object. Well-formed JSON always has non-null string property names, so this indicates deeply malformed input or a reader positioned on an unexpected token.

Source

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

                    "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> ())
        {
            // Get the attribute for the role

            if (!value.TryGetExplicitlySetAttributeForRole (role, out Attribute? attribute))
            {
                // Skip attributes that are not explicitly set

View on GitHub (pinned to 2e47b11478)

Solutions

  1. Re-create the config from a known-good default.
  2. Run the file through a JSON validator to locate the corruption.
Defensive patterns

Strategy: validation

Validate before calling

// The file is corrupt; validate it parses cleanly before loading
try { JsonDocument.Parse (File.ReadAllText (path)); }
catch (JsonException) { /* file is corrupt; regenerate from default */ }

Try / catch

try { ConfigurationManager.Apply (); }
catch (JsonException ex) when (ex.Message == "null property name.")
{ /* config is deeply malformed; regenerate from default */ }

Prevention

When it happens

Trigger: Extremely malformed JSON where the reader is on a non-string token that the loop interpreted as a property name; corrupted or hand-mangled config.

Common situations: Corrupted config file; truncated/garbled JSON; a buggy config generator.

Related errors


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