tui-cs/Terminal.Gui · error · JsonException

{propertyName}: "{property}" - {ex.Message}

Error message

{propertyName}: "{property}" - {ex.Message}

What it means

Wrapper: the outer catch in AttributeJsonConverter.Read re-throws any JsonException raised inside the property switch, prepending the current propertyName and the just-read property value/ token descriptor. It is not a standalone condition — it always wraps one of errors 21/22/23 (or a nested Color deserialize failure). Read the trailing "- {ex.Message}" for the real cause.

Source

Thrown at Terminal.Gui/Configuration/AttributeJsonConverter.cs:104

                        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);
        if (value.Style != TextStyle.None)
        {
            writer.WritePropertyName (nameof (Attribute.Style));
            writer.WriteStringValue (value.Style.ToString ());
        }

View on GitHub (pinned to 2e47b11478)

Solutions

  1. Read the substring after " - " to identify the underlying cause (Expected a string value / valid text style / Unknown property / Color error).
  2. Apply the fix for the underlying error (21, 22, 23, or 26/27).
  3. Re-validate the whole Attribute object against the three known keys.
Defensive patterns

Strategy: try-catch

Try / catch

try { ConfigurationManager.Apply (); }
catch (JsonException ex)
{
    // ex.Message shape: 'propertyName: "value" - <inner>'. Parse the suffix after ' - '.
    string inner = ex.Message.Substring (ex.Message.IndexOf (" - ") + 3);
    LogConfigError (inner); // then route to the fix for the underlying error 21/22/23/26/27
}

Prevention

When it happens

Trigger: Any of errors 21, 22, 23 firing, or JsonSerializer.Deserialize of the Color value throwing. The message format is `'{propertyName}: "{property}" - {inner}'`.

Common situations: Same as the underlying error; this wrapper just adds context (which property and what value was seen). Treat the suffix after the dash as the real diagnostic.

Related errors


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