Cloudkit subscription error: BAD_REQUEST (just production mode) - xcode

I make an App with Cloudkit subscription. (see this code).
I tested developer mode, and work fine.
I publish my App, and that is not working :(
I get the following error message (Cloudkit Dashboard Log)
error: BAD_REQUEST
operation: subscription modify
database: private
zone: _zoneWide
let predicate = NSPredicate(value: true)
let subscription = CKQuerySubscription(recordType: "recordDT",
predicate: predicate,
subscriptionID: subscriptionID,
options: [.firesOnRecordCreation, .firesOnRecordDeletion, .firesOnRecordUpdate])
let notification = CKNotificationInfo()
notification.alertBody = "change cloudkit"
notification.shouldSendContentAvailable = true
subscription.notificationInfo = notification
publicDB.save(subscription) { result, error in
if let error = error {
print(error.localizedDescription)
}
}
I found this log:
What could be the problem?

I Found the root cause of the error :)
I saw this the icloudkit dashboard webpage "Subscription types are automatically created when your app creates a Query Subscription."
This work fine the developer pages, but not true the production page :(
Must be use "deploy to production" function, after the subscripttion was created

I had a similar issue. Worked fine on dev but failed on production. The cause was my production database had not been updated with schema changes that had been made to the dev database. CloudKit automatically changes the schema of the developer databases, but you must push those changes into production. (Which is by design and a very good design choice at that.) So, if you are still having the problem, go to CloudKit dashboard and publish your changes from the developer version of your database into production.

Can you show your code for how you define publicDB and subscriptionID?
You might try saving the subscription using a CKModifySubscriptionsOperation instead of a save and see if it makes a difference.
let operation = CKModifySubscriptionsOperation(subscriptionsToSave: [subscription], subscriptionIDsToDelete: nil)
operation.modifySubscriptionsCompletionBlock = { saved, deleted, error in
if let error = error{
print(error)
}else{
print("Subscriptions saved: \(saved)\nSubscriptions deleted: \(deleted)")
}
}
publicDB.add(operation)

Related

google-drive-api method "drive.files.create" stopped working (V3 - 1.58.0.2859) and return nothing

We have a .Net app using Google Drive api to upload files to a g-drive. And it just stopped working days ago (Nov 29th). But we didn't remember doing anything changes during that time.
During the investigation, we could confirm the service account for calling the Google API are valid, since the same service account is also being used for calling other google APIs, and works fine. We also can confirm it's not a permission issue, since we even set the permission of the gdrive to allow "anyone" who has the link, to have edit permission, but the issue is still there.
Unfortunately, we cannot find any useful log, and the return message of the API call is NULL. No error code or error message returned.The only related info we saw is: on the chart of "Error by API method", it shows "drive.files.create" failed 100%.
One interesting thing is, if we disable the Google Drive API, then enable it again, it will work once, then will stop working again.
private string SaveFileToGoogleDrive(IFormFile file, string claimNumber)
{
try
{
var driveService = GetDriveServiceInstance();
var fileMetadata = new Google.Apis.Drive.v3.Data.File();
var mimeType = file.ContentType;
fileMetadata.Name = CreateFileName(file.FileName, claimNumber);
fileMetadata.MimeType = mimeType;
fileMetadata.Parents = new List { _googleSettings.GoogleDriveFolderId };
FilesResource.CreateMediaUpload request;
using (var stream = new MemoryStream())
{
file.CopyTo(stream);
request = driveService.Files.Create(fileMetadata, stream, mimeType);
request.Fields = "id";
request.Upload();
}
var googleFile = request.ResponseBody; \\The response body is always NULL, after the issue happened. :(
return googleFile.Id;
}
catch(Exception ex)
{
_logger.Error($"Google Drive exception {ex.Message} SACKTRACE: {(ex.StackTrace ?? "")} INNER EXCEPTION: {(ex.InnerException != null ? ex.InnerException.Message + "STACK TRACE:" + ex.InnerException.StackTrace ?? "" : "")}");
return string.Empty;
}
}
We found more details from the progress property in the response object, and saw the error message "The user's Drive storage quota has been exceeded.", but it does not make sense at all, since we are using "Enterprise edition" Google Workspace, which is supposed to have no limit. The service account and the key look good, GCP didn't complain at all. And that's the first thing we checked during troubleshooting.
Do you have any idea on what to do to solve the issue or what too look for when investigating this issue?
We found more details from the progress property in the response object, and saw the error message "The user's Drive storage quota has been exceeded.", but it's not make sense at all, since we are using "Enterprise editions" google workspace, which suppose has no limit. The service account and key look good, GCP didn't complain any thing. And that's the first thing we checked during troubleshooting. Anyway, the fix is: after create a new service account then use the new key of this new service account, the system back to work.

Why is dataObjectDeserializer.getObject() not present?

I have created a spring-boot server for handling stripe webhooks.
However, webhooks are working - I am getting an event, but when i try to get the value of dataObjectDeserializer.getObject() its null. Any ideas why that might be and how to fix it.
Here is the code:
Event event = null;
try {
event = Webhook.constructEvent(
payload, sigHeader, endpointSecret
);
} catch (SignatureVerificationException e) {
// Invalid signature
logger.info("Webhook error while validating signature.");
return "";
}
EventDataObjectDeserializer dataObjectDeserializer = event.getDataObjectDeserializer();
StripeObject stripeObject = null;
if (dataObjectDeserializer.getObject().isPresent()) {
stripeObject = dataObjectDeserializer.getObject().get();
} else {
// Deserialization failed, probably due to an API version mismatch.
// Refer to the Javadoc documentation on `EventDataObjectDeserializer` for
// instructions on how to handle this case, or return an error here.
}
I ran into the same issue recently.
In my case (Which I believe might be yours as well). Is that the Event is not being properly deserialized because a version mismatch between the API you are using in your account and the models of the Stripe SDK in your project. You can check this by looking into: Event.getApiVersion() and Stripe.API_VERSION.
If they differ then you will need to properly upgrade them and take in consideration migration guidelines if they apply to your scenario.
On my case since it was a first time I didn't need to go through any migration and I just simply when to my dash board and upgrade the sdk:
Dashboard Note: It displays rollback because I did upgrade it. If you haven't you will have a "Upgrade" option available.
You can find more info on their documentation page:
Upgrade Stripe API
Versioning
Hope this helps!

GraphQL requesting fields that don't exist without error

I'm trying to handle backwards compatibility with my GraphQL API.
We have on-premise servers that get periodically updated based off of when they connect to the internet. We have a Mobile app that talks to the on-premise server.
Problem
We get into an issue where the Mobile app is up to date and the on-premise server isn't. When a change in the Schema occurs, it causes issues.
Example
Product version 1
type Product {
name: String
}
Product version 2
type Product {
name: String
account: String
}
New version of mobile app asks for:
product(id: "12345") {
name
account
}
Because account is not valid in version 1, I get the error:
"Cannot query field \"account\" on type \"Product\"."
Does anyone know how I can avoid this issue so I don't recieve this particular error. I'm totally fine with account coming back with Null or just some other plan of attack for updating Schema's. But having it completely blow up with no response is not good
Your question did not specify what you're actually using on the backend. But it should be possible to customize the validation rules a GraphQL service uses in any implementation based on the JavaScript reference implementation. Here's how you do it in GraphQL.js:
const { execute, parse, specifiedRules, validate } = require('graphql')
const validationRules = specifiedRules.filter(rule => rule.name !== 'FieldsOnCorrectType')
const document = parse(someQuery)
const errors = validate(schema, document, validationRules)
const data = await execute({ schema, document })
By omitting the FieldsOnCorrectType rule, you won't get any errors and unrecognized fields will simply be left off the response.
But you really shouldn't do that.
Modifying the validation rules will result in spec-breaking changes to your server, which can cause issues with client libraries and other tools you use.
This issue really boils down to your deployment process. You should not push new versions of the client that depend on a newer version of the server API until that version is deployed to the server. Period. That would hold true regardless of whether you're using GraphQL, REST, SOAP, etc.

How do I deal with a possible exception in a Xamarin Forms application deployed to iOS or Android?

I have a finished application which I would like to make available to run on the iOS and Android platforms.  I have tested the application as much as possible and it works without problem.  But I know there is always the chance that something might go wrong and I could get an exception.
My question is how can I deal with this or what should I do. What happens on the phone, if a Forms application is deployed and there is an exception.
Would appreciate any advice or even links as to how this is handled.
If an exception is thrown and not handled by your code, the app will stop working (i.e. crash).
In order to handle these crashes we are using MS AppCenter (the successor to HockeyApp/Xamarin AppInsights).
You'll have to create a project there (one for each platform), and add the NuGet package to your projects. Afterwards you can initialize it with
AppCenter.Start("ios={Your App Secret};android={Your App Secret}",
typeof(Crashes)); // you'll get the app secrets from appcenter.ms
Crashes will be logged to AppCenter now and you'll be informed whenever there is a new crash.
Please note that it's best practice (if not required by law), that you ask the user for consent before sending the crash report (see here). You are using the delegate Crashes.ShouldAwaitUserConfirmation for that matter. You could for example show an action sheet with Acr.UserDialogs
private bool AwaitUserConfirmation()
{
// you should of course use your own strings
UserDialogs.Instance.ActionSheet(
new ActionSheetConfig
{
Title = "Oopsie",
Message = "The app crashed. Send crash to developers.",
Options = new List<ActionSheetOption>
{
new ActionSheetOption("Sure", () => Crashes.NotifyUserConfirmation(UserConfirmation.Send)),
new ActionSheetOption("Yepp, and don't bug be again.", () => Crashes.NotifyUserConfirmation(UserConfirmation.AlwaysSend)),
new ActionSheetOption("Nope", () => Crashes.NotifyUserConfirmation(UserConfirmation.DontSend))
}
});
return true;
}

parsr.com - Connection can not be established

I use the datastore of parse.com to manage the data of my apps. I use javascript by the way. I establish my connection like this:
Parse.initialize("KRCjl8ZEgNIERgXcbhbh6kfsdeXReWfA9phOY1Ql","v5uW61qzYboq64zleielyi9876sx8se");
// A Collection containing all instances of category objects.
var categoryObject = Parse.Object.extend("categories");
var CategoryCollection = Parse.Collection.extend({
model: categoryObject
});
var collection = new CategoryCollection();
collection.fetch({
success: function(categoryList) {
alert("ok");
},
error: function(collection, error) {
for(item in error) {
alert(item +" = "+ error[item]);
}
}
});
The thing is that it worked yesterday, now when I browse to www.parse.com, it says that the certificate has expired. I think it has something to do with this issue.
Can anyone tell me please what I could do now.
Thanks,
enne
We had an SSL issue this morning that caused downtime. You can read our post-mortem here: http://blog.parse.com/2012/09/10/summary-of-the-september-10-parse-service-disruption/.
The issue was resolved this morning at 8:42am and everything should be working fine now.
If you have any other issues with Parse, feel free to check out parse.com/help
If you hit parse.com, you'll get an expired SSL cert error. That's why the API calls aren't working, same thing happening for my app. I can't imagine this happening in a professional context, but there it is. I've sent a message to support. Strangely, my tweet didn't show up on #ParseIt.
Same thing is happening for me. I don't think is your code - probably a problem on their site. Hopefully it'll get resolved soon.
Parse.com is still a buggy system but you can access your data through web interface like
https://www.parse.com/apps/ispect/collections#class/
Mention you and can access to your data.

Resources