Record type UserEmailRecord must have a primary key
based on just the snippet here, which does not even show the whole message.
One possible explanation for not getting an error is that UserEmailRecord isn’t included in the RecordTypeUnion and the loaded record is some other type altogether.
There is currently no way in just the .proto to get a compound primary key. It might not be unreasonable to deduce from the record type having a record type key that [(field).primary_key = true] should mean that it gets recordType() plus that. But that would be an enhancement. You probably need to use RecordMetaDataBuilder and setPrimaryKey.