·

PipelineArgs Serialization Has a December 10 Deadline

Alex Lentz

Title card: PipelineArgs Serialization Has a December 10 Deadline. SitecoreAI post on Sitecore Saga.

When the SitecoreAI changelog dropped a note back in late September about “changes to JSON serialization”, I skimmed right past it. Serialization, sure, probably some platform plumbing. Then the follow-up landed on November 20 with an actual date in it, and that one got my attention. The PipelineArgs.DisableUnsafeSerialization feature flag goes away on December 10, 2026, and after that there’s no switching back to the old behavior.

Most of you won’t notice a thing. But if your CM solution has been around for a while (and especially if it came over from XP during a migration), there’s a decent chance some older customization is quietly relying on the exact behavior that’s being removed. Long story short, it’s a lot cheaper to find that code now than on December 11 when an editor tells you a ribbon button stopped working.

What Actually Changed

SitecoreAI is switching the Newtonsoft.Json configuration used for PipelineArgs from TypeNameHandling.All to TypeNameHandling.None. With All, every serialized object carried a $type property with its full .NET type name, and on the way back in, Json.NET happily created whatever type that property named. That’s convenient, and it’s also exactly why TypeNameHandling.All on data you don’t fully control is a well-known deserialization risk. Hence the word unsafe in the flag name.

With None, no type metadata gets written. Strings, numbers and booleans round-trip just fine. Complex objects don’t. They come back as generic JSON objects instead of your class, so the cast that used to work now blows up (or worse, quietly hands you null).

Per the Sitecore changelog, the types at risk are:

  • Custom classes – your own POCOs stuffed into CustomData
  • Interface-based objects – anything stored as IWhatever and cast back later
  • Abstract types – same problem, there’s no type name to pick the concrete class
  • Heterogeneous collections – a List<object> with a mix of types in it

Where This Bites

The hot spot is PipelineArgs.CustomData, which is a SafeDictionary<string, object>. Because it’s typed as object, it’s really easy to toss a whole model in there in one processor and pull it back out in another. That works fine as long as the args stay in memory. The trouble starts when the args get serialized and rehydrated somewhere along the way, which is the round-trip Sitecore is calling out.

The pattern I’d look for first is something like this, which I’ve seen variations of on more than one inherited solution:

public class CollectSelection
{
public void Process(PipelineArgs args)
{
var selection = new BulkTagSelection
{
ItemIds = GetSelectedIds(),
TagIds = GetChosenTags(),
RequestedBy = Context.User.Name
};
// Works in memory. After a serialize/deserialize round-trip
// with TypeNameHandling.None, this is no longer a BulkTagSelection.
args.CustomData["bulkTagSelection"] = selection;
}
}
public class ApplyTags
{
public void Process(PipelineArgs args)
{
// InvalidCastException waiting to happen
var selection = (BulkTagSelection)args.CustomData["bulkTagSelection"];
// Or the "safe" version that just returns null and skips the work
var maybe = args.CustomData["bulkTagSelection"] as BulkTagSelection;
}
}

That second flavor is the one I’d worry about more. A hard cast throws and at least shows up in the logs. An as cast returns null, the processor bails early, and nobody notices until a content author asks why their tags never got applied.

The Solution

The fix is to stop asking the serializer to remember your types for you. Store something that survives a type-less round-trip, and be explicit about what type you want back. I like wrapping that in a tiny extension class so the whole team uses the same pattern:

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Sitecore.Pipelines;
namespace Project.Foundation.Pipelines
{
public static class CustomDataExtensions
{
// Store complex models as a JSON string. Strings round-trip cleanly
// no matter what TypeNameHandling is set to.
public static void SetModel<T>(this PipelineArgs args, string key, T model)
{
args.CustomData[key] = model == null
? null
: JsonConvert.SerializeObject(model);
}
// Read it back as T regardless of what shape it arrived in.
public static T GetModel<T>(this PipelineArgs args, string key) where T : class
{
var raw = args.CustomData[key];
switch (raw)
{
case null:
return null;
case T typed:
// Still in memory, never left the process
return typed;
case string json:
return JsonConvert.DeserializeObject<T>(json);
case JToken token:
// Legacy value that was stored as an object and came back
// as a generic JSON object after deserialization
return token.ToObject<T>();
default:
return JToken.FromObject(raw).ToObject<T>();
}
}
}
}

Then the processors from earlier turn into this:

// Writing
args.SetModel("bulkTagSelection", selection);
// Reading
var selection = args.GetModel<BulkTagSelection>("bulkTagSelection");
if (selection == null)
{
Log.Warn("ApplyTags: bulkTagSelection missing from CustomData", this);
return;
}

Notice the log line. If you’re going to fail soft, at least fail loud. Future you will appreciate it.

A couple of things about the model itself. Keep it a plain concrete class with public getters and setters, and don’t type properties as interfaces or abstract base classes. If you really have a polymorphic payload, add a discriminator property (something like Kind) and pick the concrete type yourself after deserializing. Do NOT go hunting for a way to turn TypeNameHandling back on for your own data. That’s the exact thing this change is closing off.

Testing It Before the Deadline

Until December 10 the flag still exists, so you can turn the new behavior on in a non-production environment and see what breaks. Drop a patch file into your solution:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="PipelineArgs.DisableUnsafeSerialization">
<patch:attribute name="value">true</patch:attribute>
</setting>
</settings>
</sitecore>
</configuration>

Deploy that to a dev or QA environment, then actually click through the features that use custom pipelines. Custom ribbon commands and dialogs, item:saved style event handlers that kick off pipelines, anything publish related, scheduled jobs. Unit tests won’t catch this one because the problem lives in the round-trip, not in your processor logic.

And here’s the part that’s easy to forget: once you’re happy, remove the patch file. The changelog is explicit that the configuration should come out of your solution before December 10. Needless to say, a dead setting sitting in App_Config/Include is just going to confuse whoever inherits the repo next.

Finding the Code in the First Place

On a big inherited solution you probably don’t know every place CustomData gets touched. Here’s the quick PowerShell sweep I’d run from the repo root before doing anything else:

$root = Get-Location
# Every C# line that writes to or reads from CustomData
Get-ChildItem -Path $root -Recurse -Include *.cs -File |
Where-Object { $_.FullName -notmatch '\\(bin|obj|node_modules)\\' } |
Select-String -Pattern 'CustomData\s*\[' |
Select-Object @{ n = 'File'; e = { $_.Path.Replace("$root\", '') } }, LineNumber, Line |
Format-Table -AutoSize -Wrap
# Any leftover feature flag patches
Get-ChildItem -Path $root -Recurse -Include *.config -File |
Select-String -Pattern 'PipelineArgs\.DisableUnsafeSerialization' |
Select-Object Path, LineNumber

For every hit, ask one question: is the value going in a string, number or bool? If yes, move on. If it’s anything else, it goes on the list. On most solutions I’d expect that list to be short, or empty. That’s the good outcome, and it only takes twenty minutes to confirm.

Implementation Notes

  • Don’t forget third-party modules – if you pulled in a marketplace module or an old shared library with its own processors, it’s on your list too. Check whether the vendor has said anything, and test it with the flag on.
  • Legacy values in flight – the JToken branch in GetModel is there on purpose, so values written the old way still come back usable during the transition.
  • Prefer fewer in-process customizations – a lot of the code that trips on this is the kind of CM customization we try to avoid on SitecoreAI anyway. If a processor only exists to react to an event or push content somewhere, a webhook plus an external service is usually the better long-term home for it.

Wrapping Up

This is one of those changes where the platform is doing the right thing for security, and the cost to us is mostly an afternoon of grepping and clicking around a QA environment. It’s just way better to spend that afternoon in November than to spend it in December under pressure.

Remember to:

  • Search – sweep the solution for CustomData usage that stores anything other than primitives
  • Refactor – store JSON strings or primitives, and deserialize to an explicit type
  • Test – enable PipelineArgs.DisableUnsafeSerialization in a non-prod environment and exercise the real features
  • Clean up – remove the patch config before December 10, 2026

Shout-out to the folks in the community who wrote this up early and got people talking about it. If you’ve hit a weird case with this change, let me know in the comments. I’m curious what turns up out there.

Resources

Alex Lentz

Alex Lentz

Senior Solutions Architect at Americaneagle.com and two-time Sitecore Technology MVP. Building on Sitecore since 2013, mostly SitecoreAI and headless Next.js these days.

LinkedIn    GitHub

Keep reading