{"record":{"id":"0adfcec2e177f603","repo":"tui-cs/Terminal.Gui","slug":"unexpected-token-type-for-tracecategory-reader-t","errorCode":null,"errorMessage":"Unexpected token type for TraceCategory: {reader.TokenType}","messagePattern":"Unexpected token type for TraceCategory: (.+?)","errorType":"validation","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/TraceCategoryJsonConverter.cs","lineNumber":64,"sourceCode":"                {\n                    throw new JsonException ($\"Unexpected token type in TraceCategory array: {reader.TokenType}\");\n                }\n                string value = reader.GetString ()!;\n\n                if (Enum.TryParse (value, true, out TraceCategory category))\n                {\n                    result |= category;\n                }\n                else\n                {\n                    throw new JsonException ($\"Invalid TraceCategory value in array: '{value}'\");\n                }\n            }\n\n            return result;\n        }\n\n        throw new JsonException ($\"Unexpected token type for TraceCategory: {reader.TokenType}\");\n    }\n\n    public override void Write (Utf8JsonWriter writer, TraceCategory value, JsonSerializerOptions options)\n    {\n        if (value == TraceCategory.None)\n        {\n            writer.WriteStringValue (\"None\");\n\n            return;\n        }\n\n        if (value == TraceCategory.All)\n        {\n            writer.WriteStringValue (\"All\");\n\n            return;\n        }\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/TraceCategoryJsonConverter.cs#L46-L82","documentation":"Thrown by TraceCategoryJsonConverter.Read when the JSON token for a TraceCategory value is not Number, String, or StartArray. TraceCategory accepts three shapes: an integer (6), a single string (\"Command\"), or an array of strings ([\"Command\",\"Mouse\"]); anything else (true, false, null, StartObject) is rejected at the top level.","triggerScenarios":"Putting a JSON boolean, null literal, or nested object where a TraceCategory is expected — e.g. \"TraceCategory\": true, \"TraceCategory\": null, or \"TraceCategory\": { }.","commonSituations":"A config generator emits the wrong JSON kind; a user toggles a flag in a GUI editor that writes true/false; misunderstanding the schema.","solutions":["Use one of the three supported forms: integer, single member-name string, or array of member-name strings.","If you want 'no tracing', use the string \"None\" or the integer 0.","Validate the JSON kind with jq (jq type .config.json) before loading."],"exampleFix":"// before\n\"TraceCategory\": true\n// after\n\"TraceCategory\": \"None\"","handlingStrategy":"validation","validationCode":"// Confirm the token kind is one of the three supported shapes\nbool IsValidTraceCategoryToken (JsonElement el)\n    => el.ValueKind == JsonValueKind.Number\n    || el.ValueKind == JsonValueKind.String\n    || el.ValueKind == JsonValueKind.Array;","typeGuard":"static bool IsValidTraceCategoryElement (JsonElement el)\n    => el.ValueKind is JsonValueKind.Number or JsonValueKind.String or JsonValueKind.Array;","tryCatchPattern":"ConfigurationManager.ThrowOnJsonErrors = false;","preventionTips":["Use only number, single string, or string array for TraceCategory.","Avoid UI editors that write booleans for enum-like settings.","Use \"None\" for the off state instead of false/null."],"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"}