When running a service (in this case the Markdown Service Tools MultiMarkdown to RTF service), I'm getting "Couldn't communicate with a helper application." However, the actual error in console is shown below, an unexpected type error. This was working fine until High Sierra.
The service:
- takes text input, generates RTF using multimarkdown->html->textutil
- Uses pbcopy -Prefer rtf to put the result in the clipboard as rich text (rtf)
- the service retrieves the content of the clipboard and that's what it returns
Here's the error, any insight would be welcome:
<NSXPCConnection: 0x60c000300240> connection to service named com.apple.automator.xpc.runner: Exception caught during decoding of received message, dropping incoming message.
Exception: Exception while decoding argument 1 (#3 of invocation):
<NSInvocation: 0x60400026cd40>
return value: {v} void
target: {@} 0x0
selector: {:} null
argument 2: {Q} 2
argument 3: {@} 0x0
Exception: value for key 'NS.objects' was of unexpected class 'NSTextList'. Allowed classes are '{(
NSFont,
NSAttributedString,
NSDictionary,
AMXPCToken,
NSNumber,
NSData,
NSAppleEventDescriptor,
NSArray,
NSMutableAttributedString,
NSParagraphStyle,
NSURL,
NSColor,
NSNull,
NSString,
NSTextTab,
NSGlyphInfo
)}'.
I get the same error in the console about the "unexpected class". I've just done about 1.5 hours worth of trying different things and I not 100% sure what the root problem is. :(
I thought the error was with what pbcopy places on the clipboard and what "get contents of clipboard" automator task can accept. If I delete all tasks and just have the shell script task, the workflow runs without error. This means the highlighted text won't get replaced automatically, but the converted text should be available on the clipboard due to the "pbcopy" of the shell script (see foot note below). A "paste/command-v" puts the RTF converted text into the application with no error. As soon as I add the "get contents of clipboard" to the workflow, it starts generating the error. Note this was tested from the Note & Mail applications. If I stop using an application for testing and put a "get selected text" in the workflow to debug it straight in Automator, there is never an error. It always runs perfectly.
What I suspect is happening is that pbcopy is putting that NSTextList class on the clipboard. Using Automator to "run" the workflow always completes successfully. It's only when I'm running the workflow inside an application (Notes or Mail) does the error happen. It seems the applications are more strict in checking the class or more likely have a reduced class type they can accept compared to the Automator deubgger.
Having said all of that, I see no way to fix this. I think this would require to file some sort of support ticket with Apple.
Footnote - the reduced functionality where it takes two keyboard shortcuts to make this work (command whatever + command v) would be acceptable to me. However, the RTF that comes from "command v" is not rendered properly. Text in back ticks (
code
) don't render properly with this method. Bullet lists do, however. I am now wondering if something is slightly off with the RTF that is causing the class error? If I run this only in Automator and do a "get contents of clipboard", then view the "results" the text looks perfectly formatted.