CloudKit CKModifyRecordsOperation resulting in undocumented error "Internal Error" (1/3001); "MMCSEngineCreate failed"

I'm running into an undocumented error coming back from CloudKit operations.

Specifically, I'm attempting to save new records via CKModifyRecordsOperation. I'm receiving this error for each of the records in the perRecordSaveBlock callback:

<CKError 0x3018ac3c0: "Internal Error" (1/3001); "MMCSEngineCreate failed">

Is anyone else facing this error? It has been happening for several days and I'm finally getting around to reproduction with the Console app and logs. I have 16 records on my device locally that each one gets this error back.

FB16547732 - CloudKit: CKModifyRecordsOperation saving new records results in Error <CKError 0x3018ac1e0: "Internal Error" (1/3001); "MMCSEngineCreate failed">

Answered by edorphy in 826691022

If anyone at Apple is looking, or others are curious and want to try and reproduce this and share, I believe I figured out the cause.

Background: So my app captures MetricKit payloads and saves them into CoreData / SwiftData locally. After a period of time, I ship the payloads to CloudKit. This works for all of my other apps as I mentioned, my container entitlements are setup just fine, this new app has worked in the past, etc.

Cause: It appears that when I use Xcode to download the container of my app, and then restore it, that there is some residual data in this process that causes the issue. In the container I found a few directories called MMCS in CloudKit and deleted them, then restore the container to my device(s). After doing this, it worked.

It looked something like this:

Container > AppData > CloudKit > Random Folder Identifier 1 > MMCS Container > AppData > CloudKit > Random Folder Identifier 2 > MMCS

For safe measure I deleted other directories which was likely an unnecessary action as they appear to be artifacts of other frameworks, such as WeatherKit (Caches/weather-data.db and Caches/geocode_wk.db).

This is still an issue however, because many developers will take snapshots of their files this way to perform Core Data / Swift Data migration tests on their devices.

Accepted Answer

If anyone at Apple is looking, or others are curious and want to try and reproduce this and share, I believe I figured out the cause.

Background: So my app captures MetricKit payloads and saves them into CoreData / SwiftData locally. After a period of time, I ship the payloads to CloudKit. This works for all of my other apps as I mentioned, my container entitlements are setup just fine, this new app has worked in the past, etc.

Cause: It appears that when I use Xcode to download the container of my app, and then restore it, that there is some residual data in this process that causes the issue. In the container I found a few directories called MMCS in CloudKit and deleted them, then restore the container to my device(s). After doing this, it worked.

It looked something like this:

Container > AppData > CloudKit > Random Folder Identifier 1 > MMCS Container > AppData > CloudKit > Random Folder Identifier 2 > MMCS

For safe measure I deleted other directories which was likely an unnecessary action as they appear to be artifacts of other frameworks, such as WeatherKit (Caches/weather-data.db and Caches/geocode_wk.db).

This is still an issue however, because many developers will take snapshots of their files this way to perform Core Data / Swift Data migration tests on their devices.

if I receive this error code when attempting to create records, what are your thoughts on me traversing the sandbox and deleting the CloudKit directory to mitigate this?

To me, that is fine for debugging purpose, but is probably not needed to be integrated to your production code.

MMCS is a private component CloudKit uses to manage assets. You described that the issue was triggered by replacing the app container, which is reasonable to me because doing that changed the MMCS cache (the modification date, for example) and it was possible that MMCS failed due to the data integrity concern.

Replacing the app container won't happen in a production environment, and so integrating the logic to the production code seems to be unnecessary.

Hopefully a fix in 18.4 or later, but is there anything I can do safely now?

I am not sure if folks will see it an issue, given that it's only triggered in the corner case. I guess I'd suggest that you file a feedback report to see what the folks have to say – If you do so, please share your report ID here.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

CloudKit CKModifyRecordsOperation resulting in undocumented error "Internal Error" (1/3001); "MMCSEngineCreate failed"
 
 
Q