{"record":{"id":"5fb9892d0de7fd37","repo":"tui-cs/Terminal.Gui","slug":"invalid-tracecategory-value-value","errorCode":null,"errorMessage":"Invalid TraceCategory value: '{value}'","messagePattern":"Invalid TraceCategory value: '(.+?)'","errorType":"validation","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/TraceCategoryJsonConverter.cs","lineNumber":30,"sourceCode":"    public override TraceCategory Read (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)\n    {\n        if (reader.TokenType == JsonTokenType.Number)\n        {\n            // Handle numeric format: 6\n            return (TraceCategory)reader.GetInt32 ();\n        }\n\n        if (reader.TokenType == JsonTokenType.String)\n        {\n            // Handle single string: \"Command\"\n            string value = reader.GetString ()!;\n\n            if (Enum.TryParse (value, true, out TraceCategory result))\n            {\n                return result;\n            }\n\n            throw new JsonException ($\"Invalid TraceCategory value: '{value}'\");\n        }\n\n        if (reader.TokenType == JsonTokenType.StartArray)\n        {\n            // Handle array format: [\"Command\", \"Mouse\"]\n            var result = TraceCategory.None;\n\n            while (reader.Read ())\n            {\n                if (reader.TokenType == JsonTokenType.EndArray)\n                {\n                    break;\n                }\n\n                if (reader.TokenType != JsonTokenType.String)\n                {\n                    throw new JsonException ($\"Unexpected token type in TraceCategory array: {reader.TokenType}\");\n                }","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/TraceCategoryJsonConverter.cs#L12-L48","documentation":"Thrown by TraceCategoryJsonConverter.Read when the JSON token is a single string but Enum.TryParse fails to map it (case-insensitively) to a TraceCategory enum member. TraceCategory is a [Flags] enum; single-string form must be exactly one defined member name (e.g. \"Command\", \"Mouse\", \"None\", \"All\").","triggerScenarios":"A config file sets a TraceCategory-valued property (e.g. a tracing filter) to a string that isn't a TraceCategory member — typos like \"Comand\", made-up names like \"Network\", or values that only make sense as a combination but are written as a single string.","commonSituations":"Hand-editing config.json and misspelling a category; copying a category name from old docs that no longer exists after a rename; mixing the array and scalar forms incorrectly.","solutions":["Use a valid TraceCategory enum name (check the enum definition in Tracing/TraceCategory.cs for the current members).","If you want multiple categories, use the array form [\"Command\",\"Mouse\"] instead of a comma-separated string.","Use the integer form (e.g. 6) if you know the combined flags value."],"exampleFix":"// before\n\"TraceCategory\": \"Comand\"\n// after\n\"TraceCategory\": \"Command\"\n// or for multiple\n\"TraceCategory\": [\"Command\", \"Mouse\"]","handlingStrategy":"validation","validationCode":"// Validate a TraceCategory name before relying on JSON\nbool IsValidTraceCategoryName (string s) => Enum.TryParse<TraceCategory> (s, true, out _);","typeGuard":"static bool IsValidTraceCategory (string value) => Enum.TryParse<TraceCategory> (value, true, out _);","tryCatchPattern":"ConfigurationManager.ThrowOnJsonErrors = false; // logs the bad value instead of throwing","preventionTips":["Use intellisense/the enum definition to pick valid TraceCategory names.","Use the array form for multiple categories, not a comma-separated string.","Lint config JSON in CI with a schema that enumerates allowed TraceCategory names."],"tags":["config","json","tracing","tracecategory","enum"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}