microsoft/semantic-kernel · error · KernelException

Unable to deserialize ProcessEvent queue.

Error message

Unable to deserialize ProcessEvent queue.

What it means

Thrown when JSON deserialization of a ProcessEvent entry yields null. Each entry in the event collection is expected to deserialize into an EventContainer<ProcessEvent>; a null result indicates malformed or incompatible JSON.

Source

Thrown at dotnet/src/Experimental/Process.Runtime.Dapr/Serialization/ProcessEventSerializer.cs:40

        EventContainer<ProcessEvent> containedEvent = new(TypeInfo.GetAssemblyQualifiedType(processEvent.Data), processEvent);
        return JsonSerializer.Serialize(containedEvent);
    }

    /// <summary>
    /// Deserialize a list of JSON events into a list of <see cref="ProcessEvent"/> objects.
    /// </summary>
    /// <exception cref="KernelException">If any event fails deserialization</exception>
    public static IList<ProcessEvent> ToProcessEvents(this IEnumerable<string> jsonEvents)
    {
        return Deserialize().ToArray();

        IEnumerable<ProcessEvent> Deserialize()
        {
            foreach (string json in jsonEvents)
            {
                EventContainer<ProcessEvent> eventContainer =
                    JsonSerializer.Deserialize<EventContainer<ProcessEvent>>(json) ??
                    throw new KernelException($"Unable to deserialize {nameof(ProcessEvent)} queue.");
                yield return eventContainer.Payload with { Data = TypeInfo.ConvertValue(eventContainer.DataTypeName, eventContainer.Payload.Data) };
            }
        }
    }
}

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Inspect each JSON entry in the collection to find the one producing null and verify it matches the EventContainer<ProcessEvent> shape.
  2. Align producer and consumer serialization versions.
  3. Quarantine or remove malformed entries; consider adding tolerant deserialization that skips bad entries instead of aborting.
  4. Validate JSON shape (presence of 'Payload' and 'DataTypeName' fields) before deserializing.
Defensive patterns

Strategy: validation

Validate before calling

var valid = jsonEvents.Where(j => !string.IsNullOrWhiteSpace(j) && j.Trim() != "null").ToList();
var events = valid.ToProcessEvents();

Type guard

public static bool IsValidEventJson(string json) =>
    !string.IsNullOrWhiteSpace(json) && json.TrimStart().StartsWith("{");

Try / catch

try
{
    var events = jsonEvents.ToProcessEvents();
}
catch (KernelException ex) when (ex.Message.Contains("Unable to deserialize ProcessEvent queue"))
{
    _logger.LogError(ex, "One or more event entries are malformed; inspect the batch.");
    throw;
}

Prevention

When it happens

Trigger: ProcessEventSerializer.ToProcessEvents iterates a collection of JSON strings and deserializes each; any entry that deserializes to null triggers the exception, aborting the whole batch.

Common situations: Corrupted or version-mismatched event payloads persisted in Dapr, partial writes, or entries produced by a producer using a different serialization contract.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/0d4de39d3d1b07cf. Report an issue: GitHub.