{"record":{"id":"5126c5b1128293d6","repo":"ElectronNET/Electron.NET","slug":"unexpected-token-reader-tokentype-when-reading-releasenotes","errorCode":null,"errorMessage":"Unexpected token {reader.TokenType} when reading releaseNotes.","messagePattern":"Unexpected token (.+?) when reading releaseNotes\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"src/ElectronNET.API/Converter/ReleaseNotesConverter.cs","lineNumber":59,"sourceCode":"                    {\n                        // Array of strings: [\"Note A\", \"Note B\"]\n                        list.Add(new ReleaseNoteInfo { Note = reader.GetString() });\n                    }\n                    else if (reader.TokenType == JsonTokenType.StartObject)\n                    {\n                        // Array of objects: [{ \"version\": \"1.0\", \"note\": \"...\" }]\n                        var entry = JsonSerializer.Deserialize<ReleaseNoteInfo>(ref reader, options) ?? new ReleaseNoteInfo();\n                        list.Add(entry);\n                    }\n                    else\n                    {\n                        reader.Skip();\n                    }\n                }\n                return list.ToArray();\n\n            default:\n                throw new JsonException($\"Unexpected token {reader.TokenType} when reading releaseNotes.\");\n        }\n    }\n\n    public override void Write(Utf8JsonWriter writer, ReleaseNoteInfo[] value, JsonSerializerOptions options)\n    {\n        if (value is null)\n        {\n            writer.WriteNullValue();\n            return;\n        }\n\n        if (value.Length == 0)\n        {\n            writer.WriteStartArray();\n            writer.WriteEndArray();\n            return;\n        }\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/ElectronNET/Electron.NET/blob/87cc6f98b6a9c5968d7846c0e775ea713bd0d7b2/src/ElectronNET.API/Converter/ReleaseNotesConverter.cs#L41-L77","documentation":"ReleaseNotesConverter.Read throws this JsonException when it encounters a JSON token it does not handle while deserializing an Electron releaseNotes value (expected null, a single object, or an array of objects). The converter hits the default switch branch, meaning the incoming payload shape does not match any expected case.","triggerScenarios":"Deserializing a releaseNotes payload whose token is neither Null, StartArray, nor a recognized object start — e.g. a string value ('releaseNotes': 'Fixed bugs') instead of an object/array, or a number/boolean where an object was expected.","commonSituations":"Electron host/bridge version mismatch where the host sends releaseNotes as a plain string; custom IPC payloads passing through the same converter; manually crafted JSON in tests.","solutions":["Check the actual JSON payload being sent for releaseNotes and make it either null, an object, or an array of objects","Ensure ElectronNET.Host and ElectronNET.API package versions match so payload shapes agree","Inspect reader.TokenType in a debugger or log to identify the unexpected token type","If the payload is a string, parse or wrap it before deserialization"],"exampleFix":"// before\n{ \"releaseNotes\": \"Bug fixes and improvements\" }\n// after\n{ \"releaseNotes\": [{ \"version\": \"1.0.1\", \"notes\": \"Bug fixes and improvements\" }] }","handlingStrategy":"try-catch","validationCode":"// validate shape before deserializing\nusing var doc = JsonDocument.Parse(rawJson);\nvar t = doc.RootElement.GetProperty(\"releaseNotes\").ValueKind;\nbool ok = t == JsonValueKind.Null || t == JsonValueKind.Array || t == JsonValueKind.Object;","typeGuard":"bool IsValidReleaseNotes(JsonElement e) =>\n    e.ValueKind is JsonValueKind.Null or JsonValueKind.Array or JsonValueKind.Object;","tryCatchPattern":"try\n{\n    var notes = JsonSerializer.Deserialize<ReleaseNoteInfo[]>(json, ElectronJson.Options);\n}\ncatch (JsonException ex)\n{\n    logger.LogWarning(ex, \"Malformed releaseNotes payload: {Raw}\", rawJson);\n}","preventionTips":["Keep ElectronNET.API and ElectronNET.Host versions in sync","Log raw payloads when deserialization fails","Never send releaseNotes as a plain string"],"tags":["json","deserialization","electron"],"backgroundTag":"unexpected-response-shape","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"}