Why is StateTree triggering an "Array index out of bounds" exception?

I’m using two MassSpawners to spawn crowd characters like in City Sample, each with different StateTree assets. For some reason, when transitions are triggered, I get an exception on this line with error:

Array index out of bounds: 65533 from an array of size 5

It seems like the CurrentStatus.State.Index (aka Handle.Index) is 65533, which is the StateTreeHandle::FailedIndex. I set breakpoints everywhere that FailedIndex and I can’t figure out how it’s getting set to that. Anyone else run into this?

I’m on UE 5.0.3.

Turns out this is likely a bug in StateTree that is fixed after UE 5.0.3 but not yet in a released version of the engine. When I switched to using UE5 built from the ue5-main branch it fixes this issue.