SwiftData fatal error "Never access a full future backing data"

My app started crashing a ton with Xcode 16 beta 1 / iOS 18 because of "Thread 1: Fatal error: Never access a full future backing data". I was hoping this would be resolved with beta 2, but unfortunately this is not the case. I'm having a tough time reproducing this bug in a small sample project – I'd appreciate any hints as to what might be causing this.

Full error:

Thread 1: Fatal error: Never access a full future backing data - PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-coredata://10A5A93C-DC7F-40F3-92DB-F4125E1C7A73/MyType/p2), implementation: SwiftData.PersistentIdentifierImplementation) with Optional(3BF44A2D-256B-4C40-AF40-9B7518FD9FE6)

I see this when updating relationships after upserting a model object in a context. If the model object already exists and the upsert is an update the relationship updates fail with the error. If the model object does not already exist and the upsert is an insert then the relationships update fine. This looks like a bug and I cannot see any way around it.

Also getting this quite often when deleting a model

Have logged FB14083137 for the error that I am seeing. Same code that fails in iOS18 works fine on iOS17.

SwiftData fatal error "Never access a full future backing data"
 
 
Q