{"record":{"id":"dfd279f4609ccb9f","repo":"microsoft/semantic-kernel","slug":"unable-to-deserialize-kernelprocessevent-queue","errorCode":null,"errorMessage":"Unable to deserialize KernelProcessEvent queue.","messagePattern":"Unable to deserialize KernelProcessEvent queue\\.","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.Runtime.Dapr/Serialization/KernelProcessEventSerializer.cs","lineNumber":50,"sourceCode":"\n        IEnumerable<KernelProcessEvent> Deserialize()\n        {\n            foreach (string json in jsonEvents)\n            {\n                yield return json.ToKernelProcessEvent();\n            }\n        }\n    }\n\n    /// <summary>\n    /// Deserialize a list of JSON events into a list of <see cref=\"KernelProcessEvent\"/> objects.\n    /// </summary>\n    /// <exception cref=\"KernelException\">If any event fails deserialization</exception>\n    public static KernelProcessEvent ToKernelProcessEvent(this string jsonEvent)\n    {\n        EventContainer<KernelProcessEvent> eventContainer =\n            JsonSerializer.Deserialize<EventContainer<KernelProcessEvent>>(jsonEvent) ??\n            throw new KernelException($\"Unable to deserialize {nameof(KernelProcessEvent)} queue.\");\n        return eventContainer.Payload with { Data = TypeInfo.ConvertValue(eventContainer.DataTypeName, eventContainer.Payload.Data) };\n    }\n}\n","sourceCodeStart":32,"sourceCodeEnd":54,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.Runtime.Dapr/Serialization/KernelProcessEventSerializer.cs#L32-L54","documentation":"Thrown when JSON deserialization of a single KernelProcessEvent produces null. The serializer wraps each event in an EventContainer<T> and expects a non-null result; a null indicates malformed JSON or a payload that does not map to KernelProcessEvent.","triggerScenarios":"KernelProcessEventSerializer.ToKernelProcessEvent deserializes a JSON string into EventContainer<KernelProcessEvent>; if the result is null (e.g., JSON literal \"null\" or incompatible payload), the exception fires.","commonSituations":"Corrupted entries in the Dapr event queue, a payload written by an incompatible serializer/version, or a null token persisted in place of a real event. Often surfaces during process initialization when replaying queued events.","solutions":["Inspect the raw JSON string being deserialized to confirm it is a valid EventContainer payload, not a literal null.","Ensure the producer writing KernelProcessEvent entries uses the same serialization format and version as the reader.","Filter or purge corrupted entries from the event queue if they cannot be recovered.","Add a pre-check that the JSON is non-empty and not the literal token 'null' before calling ToKernelProcessEvent."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-validate the JSON is a non-null object before deserializing\nif (string.IsNullOrWhiteSpace(jsonEvent) || jsonEvent.Trim() == \"null\")\n    throw new InvalidOperationException(\"Cannot deserialize a null KernelProcessEvent entry.\");","typeGuard":"public static bool LooksLikeEventContainer(string json) =>\n    !string.IsNullOrWhiteSpace(json) && json.TrimStart().StartsWith(\"{\");","tryCatchPattern":"try\n{\n    var evt = jsonEvent.ToKernelProcessEvent();\n}\ncatch (KernelException ex) when (ex.Message.Contains(\"Unable to deserialize KernelProcessEvent queue\"))\n{\n    _logger.LogError(ex, \"Malformed event JSON; quarantining entry.\");\n    // optionally skip or move to a dead-letter store\n}","preventionTips":["Use the same serializer version to produce and consume event entries.","Pre-validate JSON entries are non-null objects before deserialization.","Consider a tolerant deserialization wrapper that logs and skips bad entries."],"tags":["dapr","process-runtime","serialization","json","event-queue"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}