I've recently added iCloud backup on my chat app. Conversations are backing up fine but some users are losing their chats and when I see the telemetry it show "BAD_REQUEST" error. I couldn't find any details or solution for it. Does anyone has any idea what it could be? My development scheme is already fully deployed to production.
BAD_REQUEST
typically means that the CloudKit server receives an invalid request. That can happen when, for example, your request has a CloudKit record or field that doesn't exist in the CloudKit schema.
You mentioned your development scheme had been fully deployed to production, but that doesn't completely rule out the possibility of having invalid requests. For example, if you are using Core Data / SwiftData + CloudKit (NSPersistentCloudKitContainer
), and the Core Data / SwiftData model in your app isn't completely mapped to the CloudKit schema, a bad request may happen.
What CloudKit API are you using? For Core Data / SwiftData + CloudKit and the CloudKit framework, you might consider capturing and analyzing a sysdiagnose to hopefully find detailed messages that indicate the concrete reason of a bad request.
If you are only using NSUbiquitousKeyValueStore
, or using file system APIs to access iCloud Drive, you don't directly get involved to CloudKit requests, and so I’d suggest that you file a feedback report with what APIs you use and how you use them for the CloudKit folks to investigate – If you do so, please share your report ID here for folks to track.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.