Why Must All Attributes in a Composite Type Be Optional?

I recently encountered an issue involving Core Data’s new Composite Attributes feature and thought I would share my experience, as well as seek clarification.

I created a composite type where all attributes were mandatory, except for one. Subsequently, I added an attribute to an entity and set its type to that composite type. Upon running the app, the console output the following error:

CoreData: error: CoreData: error: Row (pk = 85) for entity ‘(EntityName)’ is missing mandatory text data for property ‘(propertyName)’

The way I resolved this was by removing the composite type attribute from the entity, after which the error no longer appeared. I also observed that in another entity, where a different composite type is used, all the attributes were optional — and no error occurred.

This raises the question: why must all attributes in a composite type be optional? Furthermore, why does Xcode not inform the developer of this requirement? I have reviewed both the documentation and the WWDC23 “What’s New in Core Data” session, but neither mentions that having non-optional attributes within a composite type will cause such errors and lead to unpredictable application behaviour.

Additionally, this issue remains unresolved in another area I raised previously in this topic:

Composite Attributes feature requires tvOS deployment target 17.0 or later

Composite Attributes feature requires watchOS deployment target 10.0 or later

However, I do not have a tvOS or watchOS target, nor do I intend to add one.

Could someone from Apple, or anyone with more experience, please clarify why all attributes within a composite type must be optional? And could it be possible for Xcode to flag this at compile time, rather than failing at runtime?

Thank you in advance.

Why Must All Attributes in a Composite Type Be Optional?
 
 
Q