I may have solved the crash even if I do not know why the URI query failed. I'm assuming the persistent. history tracking probably isn't the issue or there's something more to it.
I think my issue was where the nspredicate came from that I was modifying.
To easily setup a fetch request I wrap it with a view container like this
DynamicFetchView(
predicate: nil,
sortDescriptors: sort,
fetchLimit: 10
) { (items: FetchedResults<MyItem>) in
...
}
Then using the mentioned function I would do items.nsPredicate = updateNSPredicate(for: query). I assume between updating the Tag with its new items and whatever else happens to the SwiftUI view as part of the data changing, then I hit this problem.
So I've added a state object to hold the predicate and pass that to the DynamicFetchView and update the state predicate instead.
@State private var predicate: NSPredicate? = nil
...
DynamicFetchView(
predicate: predicate,
sortDescriptors: sort,
fetchLimit: 10
) { (items: FetchedResults<MyItem>) in
...
}
...
predicate = updateNSPredicate(for: query)
It would be good to know why the URI 'contains' query breaks and string 'contains' does not. I can make some educated guesses, but at the very least I do not think I need to worry about this crash for now. I've tried dozens of times with no problems.