{"record":{"id":"0d3e2eba00c3b1cb","repo":"ElectronNET/Electron.NET","slug":"unsupported-token-r-tokentype","errorCode":null,"errorMessage":"Unsupported token {r.TokenType}","messagePattern":"Unsupported token (.+?)","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"src/ElectronNET.API/Serialization/JsonToBoxedPrimitivesConverter.cs","lineNumber":110,"sourceCode":"                    if (DateTime.TryParse(s, out var dt))\n                    {\n                        return dt;\n                    }\n\n                    if (TimeSpan.TryParse(s, out var ts))\n                    {\n                        return ts;\n                    }\n\n                    if (Guid.TryParse(s, out var g))\n                    {\n                        return g;\n                    }\n\n                    return s;\n\n                default:\n                    throw new JsonException($\"Unsupported token {r.TokenType}\");\n            }\n        }\n\n        public override void Write(Utf8JsonWriter writer, object value, JsonSerializerOptions options)\n        {\n            if (value is null)\n            {\n                writer.WriteNullValue();\n                return;\n            }\n\n            writer.WriteStartObject();\n            writer.WriteEndObject();\n        }\n    }\n}","sourceCodeStart":92,"sourceCodeEnd":126,"githubUrl":"https://github.com/ElectronNET/Electron.NET/blob/87cc6f98b6a9c5968d7846c0e775ea713bd0d7b2/src/ElectronNET.API/Serialization/JsonToBoxedPrimitivesConverter.cs#L92-L126","documentation":"JsonToBoxedPrimitivesConverter.ReadValue handles primitives, objects, arrays, and a few special cases (e.g. Guid/DateTime strings); any remaining JsonTokenType reaches the default branch and throws this JsonException naming the unsupported token. It means the converter received a token kind it was never designed to box.","triggerScenarios":"Feeding the converter JSON containing token types outside its supported set — e.g. a StartObject/PropertyName at top level where only a primitive/array was expected, or exotic values in an unexpected position.","commonSituations":"Registering this converter for types it cannot represent; calling Electron APIs with payloads of the wrong shape; deserializing a root value that is an object when a primitive was expected.","solutions":["Inspect the logged r.TokenType to see which token is unsupported","Check the expected JSON shape of the API call and send the correct type (number, string, bool, array)","Do not route complex objects through JsonToBoxedPrimitivesConverter; use a typed converter instead","Verify converter registrations in ElectronJson options are not applied to the wrong type"],"exampleFix":"// before\n// sending an object where a primitive is expected: options = { size: 10 }\nsend(\"setSize\", options);\n// after\nsend(\"setSize\", 10); // pass the primitive value directly","handlingStrategy":"validation","validationCode":"// confirm only primitives/arrays are routed through this converter\nbool supported(JsonElement e) => e.ValueKind is\n    JsonValueKind.Number or JsonValueKind.String or JsonValueKind.True\n    or JsonValueKind.False or JsonValueKind.Null or JsonValueKind.Array;","typeGuard":null,"tryCatchPattern":"try\n{\n    var value = JsonSerializer.Deserialize<object>(json, ElectronJson.Options);\n}\ncatch (JsonException ex) when (ex.Message.Contains(\"Unsupported token\"))\n{\n    logger.LogWarning(ex, \"Unsupported token in payload — check argument shape\");\n}","preventionTips":["Pass primitive values directly instead of wrapping in objects when the API expects primitives","Don't register JsonToBoxedPrimitivesConverter for complex types","Log r.TokenType / payload on failure to identify the shape mismatch"],"tags":["json","deserialization","converter"],"backgroundTag":"unsupported-operation","analyzedSha":"87cc6f98b6a9c5968d7846c0e775ea713bd0d7b2","analyzedAt":"2026-09-14T03:09:47.608Z","contentChangedAt":"2026-09-14T03:09:47.608Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}