Script Error: SyntaxError: JSON Parse error: Unexpected identifier "drafts" Line number: 53, Column 35

Hi,
getting following error with TADpoLe Library for all actions:

Script step completed.
Script step completed.
Script step completed.
Script step completed.
Script Error: SyntaxError: JSON Parse error: Unexpected identifier “drafts”
Line number: 53, Column 35

Drafts Version 31.0.1 (iOS and macOS) and new imported TADpoLe Actions.

Regards,
Dietmar

Re. The discussion in that thread I guess that this thread will do as a place to continue a separate discussion.

As yet I have been unable to reproduce the issue. So, what commonalities do we have amongst those experiencing the issue (e.g. hardware and software versions)? Perhaps it is worth (re)sharing the latest behaviors for those individuals who flagged up over the past few weeks on Twitter and the Draft Slack space. After all, it seems it has been inconsistent even for individuals by my understanding of what has been flagged to date.

The more information available, the greater the chance or being able to reproduce it and track it down.

What I can’t do is try and debug something like this remotely. I need to be able to try things and what might take hours for me to try at my computer could take a hundred times that if trying to step someone through things remotely - which would be entirely impractical for all concerned.

There is obviously an issue somewhere, so I would very much like to get to the bottom of it!

1 Like

@sylumer Just took a look at this with a clean install of TAD.

The problem is in the below function, in the TAD action:

function getMinVerForGroup(p_strActionName)
{
	let ac = Action.find(p_strActionName);
	if (ac == undefined) return 0;
	else
	{
		let intVer = parseInt(JSON.parse(decodeURIComponent(ac.installURL.replace("drafts5://action?data=",""))).actionDescription.split("\nVERSION:")[1])
		if (isNaN(intVer)) return 0;
		else return intVer;
	}
}

The default installURL values for actions are now drafts://, not drafts5://, and you are getting an error trying to parse out a value.

3 Likes

Okay, thanks. I’ll put a tweak out shortly based on that and see if it helps. Still seems were that it’s not been a global effect though. But if that’s all it turns out to be, so much the better :sunglasses:

2 Likes

I just made this one change and it appears to have fixed my library. Thank you guys :slight_smile:

1 Like

I have just finished pushing an update to the directory for all of the ThoughtAsylum action groups.

The core group update includes the change suggested by @agiletortoise . It’s obviously worked for @Blue. Hopefully, it’ll do the trick for others too. Do post back here and let us know one way or the other.

The other changes to the action groups are mostly just fixing typos I spotted - I can spell, I’m just really(!) bad at typing :laughing:

Updates are listed in the usual change log location, you can directly jump to today’s list here:

4 Likes

Good and very fast job! :wink:

Thank you very much for fixing it.

Regards,
Dietmar

1 Like

thanks a lot! - fixed it again on my iPhone and its working on my other devices now, too :slight_smile:

Hm. I deleted and reinstalled my TAD groups yesterday and still saw this error. Should a fresh install of TAD still be affected by this?

Should just be applied by an update of the core action group.

Would have thought so, but I was doing some spring cleaning anyway… :wink:

Still, the error persists for me. I’ll dig a bit deeper into my setup to see if there’s anything I’m overlooking.

Sorted. Had a copy of the TAD core action lurking outside the core action group. My bad.

Glad it was an easy fix. :+1:t2:

I was still having issues with a few actions - namely the ones that export keyboard shortcuts… but I’m almost positive I have the definite fix. A total of 5 changes to tad.js.

Idk how useful the Working Copy commit output below might be, but drafts5 was still present on lines:

  • 16
  • 7233
  • 7643
  • 7707
  • 7718

TAD Library Fix Diff

From 1cf16d7a42c69034eb3b01bf7a4a1e1a3dbb25cb Mon Sep 17 00:00:00 2001
From: David Blue <davidblue@extratone.com>
Date: Sat, 21 May 2022 09:39:48 -0500
Subject: [PATCH] #64

> This is the fix for my TAD Library issues! I’ve got a handy screenshot to comment on the issue.
---
 library/Scripts/tad.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/library/Scripts/tad.js b/library/Scripts/tad.js
index 43e7ef8..959f2e9 100644
--- a/library/Scripts/tad.js
+++ b/library/Scripts/tad.js
@@ -13,7 +13,7 @@
 Action.prototype.TA_populateMore = function()
 {
 	//Get the installation data for an action from its install URL
-    let jsonActionData = JSON.parse(decodeURIComponent(this.installURL.replace(“drafts5://action?data=“,””)));
+    let jsonActionData = JSON.parse(decodeURIComponent(this.installURL.replace(“drafts://action?data=“,””)));
 
     //Populate the additional properties.
     //  For ease of recognition, and to avoid clashes with future updates that may
@@ -7230,7 +7230,7 @@ class TadLibrary
     // Used to quickly replace the TAD-Library action contents from the tad.js library file.
     TA_buildLibraryAction()
     {
-        const strCall = “drafts5://action?data=“;
+        const strCall = “drafts://action?data=“;
 
         let fmCloud = FileManager.createCloud();
         let strScript = fmCloud.readString(“/Library/Scripts/tad.js”);
@@ -7640,7 +7640,7 @@ class TadMiscellaneous
         let astrNames = [];
 
         //Convert action group installation link data to JSON
-        let strLink = p_strActionGroupLink.replace(“drafts5://actionGroup?data=“,””);
+        let strLink = p_strActionGroupLink.replace(“drafts://actionGroup?data=“,””);
         strLink = decodeURIComponent(strLink);
         let jsonData = JSON.parse(strLink);
 
@@ -7704,7 +7704,7 @@ class TadMiscellaneous
     TA_actionGroupLinkToName(p_strActionGroupLink)
     {
         //Convert action group installation link data to JSON
-        let strLink = p_strActionGroupLink.replace(“drafts5://actionGroup?data=“,””);
+        let strLink = p_strActionGroupLink.replace(“drafts://actionGroup?data=“,””);
         strLink = decodeURIComponent(strLink);
         return JSON.parse(strLink).name;
     }
@@ -7715,7 +7715,7 @@ class TadMiscellaneous
     TA_actionGroupLinkDocument(p_strActionGroupLink)
     {
         //Convert action group installation link data to JSON
-        let strLink = p_strActionGroupLink.replace(“drafts5://actionGroup?data=“,””);
+        let strLink = p_strActionGroupLink.replace(“drafts://actionGroup?data=“,””);
         strLink = decodeURIComponent(strLink);
         let jsonData = JSON.parse(strLink);
         let strDoc = “# “ + jsonData.name + “\n”;
--
Working Copy 5.2.1
1 Like

Okay, no one had reported anything about any actions no longer working, so I hadn’t looked into this. The original protocol change was relating to the URL built into an action rather than any in the library and I’d fogotten I’d got anything in there that was using them.

Those protocol name changes, plus a few other small tweaks should now appear in the library which the action group should pull in. This should be picked up by maual or automatic refreshes - whatever you have enabled.

The latest version of the library code is linked to from the website and for convenience, here’s the direct link:

The library file is built via a script from a set of other files which also do some additional file management and generate the code documentation, so the line numbers for the files the changes were made in are somewhat different.

If anyone does come across any issues with any of the actions or library functions do let me know. I’m usually pretty responsive to such things.

1 Like