Statuscode 503 (Service Unavailable) when decrypting CoreML model

Yesterday evening, upon a fresh install, my app was not able to decrypt the CoreML model and kept returning status code 503. I understood this as: Apple's service to download the decryption key is not available at the moment. This problem persisted for at least 8 hours. Three questions:

  1. Does that occur more often? It means that during such times, new customers of my app will not be able to use the app.
  2. Anyone has some sample code on how to identify this situation / extract the status code from the error object? (Instead of error 'You need an internet connection' I would like to issue error 'Apple server currently not available - try again later')
  3. Anyone knows how to force/simulate this situation so that I can analyse the error object and see how I can identify the situation?

Below my code to retrieve the model:

NSURL *modelUrl = [[NSBundle mainBundle] URLForResource:modelName withExtension:@"mlmodelc"];

[MLModel loadContentsOfURL:modelUrl
                 configuration:[[MLModelConfiguration alloc] init]
             completionHandler:^(MLModel *loadedModel, NSError *error) {
        if (nil == loadedModel) {
            NSLog(@"Error loading model: %@", (nil != error) ? error : modelUrl);


Accepted Reply

Sorry about the disruption. We root-caused the issue and addressed it and there are guardrails in place to ensure this does not repeat.

Does that occur more often? It means that during such times, new customers of my app will not be able to use the app.

No, this is the first time since the feature went public more than 2 years back and we are taking steps to make sure this won't happen.

Anyone has some sample code on how to identify this situation / extract the status code from the error object? (Instead of error 'You need an internet connection' I would like to issue error 'Apple server currently not available - try again later')

The returned error should be MLModelErrorModelDecryptionKeyFetch. Yes, this would be the error even when the device is offline.

Anyone knows how to force/simulate this situation so that I can analyse the error object and see how I can identify the situation?

There's no clear way to simulate / force this scenario.

Replies

Sorry about the disruption. We root-caused the issue and addressed it and there are guardrails in place to ensure this does not repeat.

Does that occur more often? It means that during such times, new customers of my app will not be able to use the app.

No, this is the first time since the feature went public more than 2 years back and we are taking steps to make sure this won't happen.

Anyone has some sample code on how to identify this situation / extract the status code from the error object? (Instead of error 'You need an internet connection' I would like to issue error 'Apple server currently not available - try again later')

The returned error should be MLModelErrorModelDecryptionKeyFetch. Yes, this would be the error even when the device is offline.

Anyone knows how to force/simulate this situation so that I can analyse the error object and see how I can identify the situation?

There's no clear way to simulate / force this scenario.

Thank you for your reply, I appreciate it. (Also, by the way: thank you for the feature of model encryption - it was much needed.) While available for more than 2 years, I only now switched to an encrypted model and currently in the process of testing it - so this is quite a coincidence. Based on your reply, I will stick with my current error message.