Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttscoff/a1a94f53c88e70d408d3232cb12d170b to your computer and use it in GitHub Desktop.
Save ttscoff/a1a94f53c88e70d408d3232cb12d170b to your computer and use it in GitHub Desktop.
I can not solve this one.

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:

  1. takes text input, generates RTF using multimarkdown->html->textutil
  2. Uses pbcopy -Prefer rtf to put the result in the clipboard as rich text (rtf)
  3. 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
)}'.
@zanyterp
Copy link

Are you seeing the same thing that if you run the workflow manually inside Automator it is working?
How did you grab the detailed message string out of console? (Or, with my luck, I am seeing something different just with the same obscure message).

@hartmms
Copy link

hartmms commented Apr 13, 2018

I have the same issue, so you are not alone :) I'll do some more debugging on this later to see if I can figure out what the problem is. It's not limited to Mail. Notes throws the same dialog box error.

If I use the automator "run" with a "get selected text" box at the top (to emulate the text that comes in from the application), it looks like it runs perfectly. Seems like there is a problem with the last box that is supposed to replace the original text with the newly modified text.

@hartmms
Copy link

hartmms commented Apr 15, 2018

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.

@hartmms
Copy link

hartmms commented Apr 15, 2018

Ok, there is something about the generated RTF that is throwing off the automation/workflow. If I highlight text in a app that has no markdown on it and run the workflow, I get no error. If I have text with only code, I get no error. Bulleted lists generates the type error above. Horizontal rules don't render at all, but generate no error. Tables hag the current window and make you do a force quit. Block quotes work, and they show up a italics. Links work in Notes but in Mail they only show up as blue, underlined text you can't click on.

So I think we can conclude that Apple has changed how it interprets RTF code in recent OS releases and this is why this fails.

I wasn't wanting to figure out how to write RTF, but I suspect if I want this to start working I'll have to.

This should also be posted over on the MultiMarkdown6 repo since it's that binary that is actually doing the RTL rendering.

@hartmms
Copy link

hartmms commented Apr 15, 2018

Multimarkdown6 git wiki says RTF is not supported yet. I tried multimarkdown5, but it too generates that error. I even went back to the really old "peg-markdown" version from 5 years ago and it too generates the error. More evidence that it's a change in how RTF works in newere macOS versions.

@apophenist
Copy link

Hi all

I'm having the same issue using Brett's Markdown Service Tools - specifically markdown to RTF. This is the one required for email.

I've tried this in High Sierra and again Mojave. I've also tried installing some MultiMarkdown tools via brew.

Is anyone able to resolve this?

@johnwickerson
Copy link

johnwickerson commented Dec 14, 2018

@apophenist @hartmms I have found a partial workaround. I'm using the Markdown-to-RTF service in Mac Mail on Mojave. Text like this

hello **world**

works fine. But if I include bullets like this

* hello **world**

then I get the "Couldn't communicate with a helper application" error. So it looks like lists are off the menu for the time being.

Interestingly, if I now revert to my first example

hello **world**

then I get the error again! I found that this can be fixed by copying something else (any random piece of text) to the clipboard, and then trying again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment