CloudKit subscription internal server error - xcode

I am trying to subscribe to iCloud changes but I keep getting an internal sever error. Saving and fethcing data from iCloud works, but I can not fetch nor save subscribtions.
Anyone know what could be the problem?

I have found the problem. CloudKit is very poorly documented when it comes to errors. Looks like you receive an internal server error when trying to subscribe for record changes, using a record type which does not exist yet. Weird, hope it helps someone in the future!

I have also noticed that once you encounter an error subsequent calls to CloudKit seem to fail silently. Perhaps its normal iOS behaviour, and I need to reset the error code if it gets set. Maybe someone else can comment.

I had the subscriptions working correctly until I added the subscriptionID. I then started receiving the "Internal server error". I was using the function:
let subscription = CKQuerySubscription(recordType: kActionFigureSpecificsRecord,
predicate: predicate,
subscriptionID: subscriptionId,
options: [.firesOnRecordCreation, .firesOnRecordUpdate, .firesOnRecordDeletion])
subscriptionID
The unique name of the subscription. This string must be unique in the specified database and must not be nil.
After reading the documentation, I realized that the subscriptionID needs to be unique, although the documentation wasn't particularly clear regarding unique relative to what. I believe the unique criteria is with respect to other database ID.names, such as other recordID.recordName. I had my subscriptionID string the same value as a recordID.recordName for the table on on which the subscription acted for the relevant record. When I appended _Subscription to the subscriptionID string (i.e., name), the subscription registered fine.

Related

MassTransit StateMachine correlation by Int

New to Masstransit here and I wanted to correlate my message with an int value (let's call it OrderId of type INT. I will use the same order management example from Masstransit).
I wanted to see if anyone was able to use an int to correlate events and messages in Masstransit.
I used this code in my events (both the events)
x.CorrelateById<int>(state => state.OrderId, context => context.Message.OrderId)
This compiles fine but then throws and exception
NotImplementedByDesignException. Masstransit doc says : "Redis only supports event correlation by CorrelationId, it does not support queries. If a saga uses expression-based correlation, a NotImplementedByDesignException will be thrown."
I am using CorrelateById() so not sure why I am seeing this exception. I don't see any query here (or is it this func that returns the OrderId? The correlationId has a similar expression although it takes only one argument of type: Func<ConsumeContext<TMessage>, Guid> selector)
All I want is to be able to correlate message and event by an Int prop coming to my first event of the state machine. (That I have no control over by the way).
I feel creating another GUID just for Masstransit and link it to that OrderId is not the best option here.
My other question: is there any out of the box way in MassTransit to get the all event data for a specific CorrelationId (event sourcing style). I saw there was a MassTransit.EventStoreIntegration repo on github but since we can get the last version of the state instance I thought there would be a way to see all state instances/ or messages being persisted then pulled.
Sure I can see that in the log but I would like to see only the state changes that were pushed.
Thanks
Correlation by anything other than the Guid CorrelationId property is a query. And, as you've found out, Redis doesn't support queries. If you need to correlate events using a type other than a Guid, Redis is not an option.
As per #Chris answer, and because I wanted to use an INT property and still use redis, I used Guid CorrelationId that was generated from that INT value with padded zeros.
CorrelationId = new Guid(OrderIdIntValue.ToString().PadLeft(32, '0'))
I am aware of the Guid vs int discussion in distributed systems.
For my case this works with no issues since that Int value is generated by a unique source of truth (that I consume and don't have control over).

error: No usable messages given the current slot and sessionAttribute set

I made a chatbot in lex and for one particular intent, Lex is throwing the error,
An error has occurred: Invalid Bot Configuration: No usable messages
given the current slot and sessionAttribute set.
This error comes regardless of the input in case of that intent.
I am not using any lambda functions at this point for this intent.
Can someone guide me what this means? I am new to lex and I did not find references to what this error is about.
Recently I got the same error with the test of my bot after saving some changes. After a while, finally, I found out that it was because my confirmation message was using some slots not defined at that point.
Example:
Let's assume we have:
one required slot {name}
one optional slot {age}
and the confirmation message is "Your name is {name} and your age is {age}, is that right?"
If Lex reaches the point to ask for the user confirmation and {age} was never assigned whether in any utterance or a lambda function, then Lex will return this error.
You must ensure that all slots used in messages are defined.
I believe this error occurs because you have not configured Lex to have a response message set for that particular intent's CodeHook or Fulfillment.
If you are not using a Lambda Function for Fulfillment, be sure to select 'Return Parameters to Client' in the 'Fulfillment' section, then also supply a response message below that in 'Response' section.
Here's where to find that in the Lex Console:
when I had the error it was because my response was attempting to use a slot that I had deleted {reward}, check your response to make sure you are not attempting to add an inactive slot. Also, Make sure your intent is set to the Latest version.

Selecting an outgoing mail message programmatically

Here's what I'm attempting to do: Let's assume that you are in mail and create a New blank mail message, then enter some data into it, such as body copy, etc. (in my case, the message was created through scripting bridge using the "Mail Contents of this Page" from safari... the main purpose of this process for my application.)
From my application, I want to select that message and assign it to:
MailOutgoingMessage *myMessage;
so that I can programmatically add recipients. I've tried several ways of doing this which seemed logical, but so far I haven't found the right combination, and the header file doesn't seem to be very clear to me (I'm new to scripting bridge.)
My initial thought was to try this:
mailMessage = [[mail outgoingMessages] lastObject];
Which should grab the last outgoing message created. It seems to work in that I am able to add recipients to mailMessage (though there have been a few times that I received unexpected results when multiple outgoing messages exist, such as adding the recipients to the wrong message) but attempting to log the subject line of the message:
NSLog(#"Subject = %#",[mailMessage subject]);
always returns NULL even though there is a subject clearly viewable in the subject field of the message. NULL is returned for any other parameter as well.
I'm gathering it must be a problem with my assignment to mailMessage above, because the only time I receive a NULL for message properties (or receive unexpected results) is if I try to point mailMessage to an existing outgoing message. If I create the mail message with scripting bridge, then I can retrieve all of the properties correctly.
Does anyone understand the hierarchy of the Mail scripting enough to tell me why I am getting NULLs for the parameters using the above assignment for mailMessage? What would the simplest way be go grab my message so that I can add recipients and later call the:
[myMessage send];
method? Any insight would be helpful. I've spent a week going through the mail.h header file and am quite literally at a loss as to what else to try at this point.
There's no way to (send, get or set the properties of the outgoing message) that the user or Safari has created.
It's a bug (it stopped working since Mac OS X 10.4), or some privacy/security considerations.

Why would a WCF OracleDB receive location be triggered by its FK instead of an actual update on its table?

Strange behavior in our receive locations:
RL_REPRESENTATIVE is waiting for a notification from the REPRESENTATIVE table (fields: (PK)id, fname, lname, etc).
RL_CLIENT_REPRESENTATIVE is waiting for a notification from the CLIENT_REPRESENTATIVE table (fields: (FK)id_rep, (FK)id_client).
When both of the locations are active and I commit a change in the CLIENT_REPRESENTATIVE.id_rep table I get a couple of warnings (apparently from RL_REPRESENTATIVE).
The adapter "WCF OracleDB" raised an error message. Details "System.InvalidOperationException: The notification query returned an error. Info="Error". Source="Data". Type="Change".
at Microsoft.Adapters.OracleDB.OracleDBInboundContract.Notification_TryReceive(OracleCommonExecutionHelper executionHelper, Message& wcfMessage)
at Microsoft.Adapters.OracleDB.OracleDBInboundContract.TryReceive(TimeSpan timeout, Message& message, IInboundReply& reply)
at Microsoft.ServiceModel.Channels.Common.Channels.AdapterInputChannel.TryReceive(TimeSpan timeout, Message& message)
at System.ServiceModel.Dispatcher.InputChannelBinder.TryReceive(TimeSpan timeout, RequestContext& requestContext)
at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.TryReceive(TimeSpan timeout, RequestContext& requestContext)".
and
The adapter "WCF OracleDB" raised an error message. Details "The WCF service host at address oracledb://d01-isis:1521/D01ISIS/Dedicated?CallingTable=REPRESENTATIVE has faulted and as a result no more messages can be received on the corresponding receive location. To fix the issue, BizTalk Server will automatically attempt to restart the service host.".
Otherwise the process that is activated by a modification in CLIENT_REPRESENTATIVE takes place with no problems.
(If I update, instead, id_client in CLIENT_REPRESENTATIVE - the error comes from another receive location that subscribes to notifications from the CLIENT table.)
Two further clues:
If I disable RL_REPRESENTATIVE, the warnings won't appear.
If I update both CLIENT_REPRESENTATIVE.id_rep and REPRESENTATIVE.fname and commit both in the same transaction, the warnings won't appear.
Note that there are no triggers in either tables and all my timeouts are set to almost 24 hours.
I suspect that the FK constraint does its job in a way that ends up sending a notification to the port but I never get the actual message that I'm supposed to receive.
Question: Is there a parameter in Oracle that controls this behavior? Have any Biztalk devs ever run into this problem?
It could be:
the order in which things are saved.
a transactional problem, receive locations on seperate transactions, therefore it looks like related items are missing
a locking problem related to the transactional problem
The way to track it down would be to setup profiling on the database, and see exactly which commands are sent in which order.
In the end, the solution was to change a flag in all the receive locations (NotifyOnListenerStart) to "false".
After further development, this solution was not complete - the errant triggering is occurring again - so I'm toggling the check to off until I (or someone else) finds the correct solution.
Edit: This is a side-effect of the FK, changing its value seems to trigger a notification of a change in the table containing the PK (despite there not being any).

Using the xmpp4r Ruby gem, how can I synchronously discover if a contact is online?

I'm new to XMPP and the xmpp4r library, so please forgive my noob question if this is obviously documented somewhere.
What's the most straightforward way, in a synchronous manner, to find out if a given JID is online? (so that I can call something like is_online?(jid) in an if statement)
My details:
I'm writing a Sinatra app that will attempt to send a message to a user when a particular url gets requested on the web server, but it should only try to send the message to the user if that user is currently online. Figuring out if a given JID is online is my problem.
Now, I know that if I connect and wait a few seconds for all the initial presence probe responses to come back to the Roster helper, then I can inspect any of those presences from my Roster and call #online? on them to get the correct value. But, I don't know when all of the presence updates have been sent, so there's a race condition there and sometimes calling #online? on a presence from my roster will return false if I just haven't received that presence probe response yet.
So, my current thinking is that the most straightforward way to find out if someone is online is to construct a new Presence message of type :probe and send that out to the JID that I'm interested in. Here's how I'm doing it right now:
#jabber is the result of Client::new
#email is the jid I'm interested in polling
def is_online?(jabber, email)
online = false
p = Presence.new
p.set_to(email)
p.set_from(jabber.jid)
p.set_type(:probe)
pres = jabber.send(p) do |returned_presence|
online = returned_presence.nil?
end
return online
end
Now, this works in cases where the user is actually online, but when the user is offline, it looks like the presence probe message that comes back is being caught by some other presence_callback handler that doesn't know what to do with it, and my is_online? function never finishes returning a value.
Can anyone help me by providing a simple example is_online? function that I can call, or point me in the right direction for how I can detect when the roster is done getting all the initial presence updates before I try checking a presence for #online?
As it turns out, there's not a synchronous way to ask for a JID presence. You've just got to ask for what you want, then wait for your response handler to fire when the response arrives.

Resources