Intermittent SMSTableDialogController (null selector) error on Myriad Tables

Hoping anyone could just give me pointers about what this means or what could be causing it.

I’ve got about 60 users on a new script I wrote using Myriad Tables. It just runs fine for most of them most of the time.

But there have been several intermittent reports of this error:

-[SMSTableDialogController (null selector)]: unrecognized selector sent to instance
0x13724d90
-[SMSTableDialogController (null selector)]: unrecognized selector sent to instance 0x13724d90 (-10000)

When people get that, other users can run the same script on the same data and it does not get that error, and works fine all the way through.

I’ll post the script, but you can only really read it and not run it… it calls library handlers, that call library handlers, that read encrypted credentials and decrypt them, that call API’s… it’s nested dependencies all the way down. All the Myriad Tables stuff is right there though.

Maybe there’s a bug in the script itself, but I suspect it’s more likely something environmental, given the intermittent nature.

The script is distributed as a .app file over Dropbox on a volume that’s read-only to the users. Could it be getting mad that the script uses Applescript Properties, but can’t write them back to the file? We have plenty of other scripts using Properties that run fine consistently off Dropbox.

One user was getting the error consistently on repeated attempts, restarted their computer, and has never seen it again on many uses.

Another user was getting it intermittently, then copied the .app bundle out of Dropbox, and hasn’t seen the error since… but they were only getting it intermittently to begin with, so I’m not yet convinced moving the file was related.

I also read several other forum thread here like this, and while they aren’t getting the same error, it made me wonder if this is permissions related. I’m not distributing Myriad Tables inside the script and re-signed; the signed version also lives on Dropbox, and the user’s Script Libraries folder is symlinked to the Dropbox folder. This setup works fine with 21 other libraries we’ve got there collectively called 10,000 times a day, so that setup is definitely basically functional. But thought I’d bring it up, just in case. I could try bundling it, if anyone thinks that could be related.

Just looking for theories here on what this could be and how I could make this more reliable.

Anyway, if anyone can give me insight into possible causes of the error, or possible solutions, let me know.

--*SaveFiletypes*app*SaveFiletypes*

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use script "Myriad Tables Lib" version "1.0.9"

tell script "CRM_AND_ORDER_RELATED"
	set chromeOrderNumbers to get_orderIds_from_chrome_tabs()
	set frontOrder to get_orderId_from_active_chrome_tab()
end tell
if (count of chromeOrderNumbers) > 1 then
	set theOrderNos to choose from list chromeOrderNumbers with prompt "Select which order numbers you want to copy files between." & return & "(If your order doesn't show, open it in Chrome.)" default items {frontOrder} with multiple selections allowed
else
	set theOrderNos to chromeOrderNumbers
end if
if chromeOrderNumbers is {} then
	display dialog "This script looks for orders open in Chrome Tabs to provide options for which orders to operate on, but no CRM Order Pages were found open in Chrome." & return & return & "Please open at least one order and try again." buttons {"OK"} default button "OK"
	if the button returned of the result is "OK" then error number -128
end if
set orderData to {}

set progress total steps to (count of theOrderNos)
set progress completed steps to 0
set progress description to "Gathering data on orders."

repeat with anOrder in theOrderNos
	set progress additional description to "Getting CRM Data on Order " & anOrder
	set progress completed steps to progress completed steps + 1
	tell script "CRM_AND_ORDER_RELATED" to copy get_order_info(anOrder) to end of orderData
end repeat

set chartData to {}
set higlightedRows to {}
set rowCount to 0
set foundMasters to {}

repeat with orderCount from 1 to count of orderData
	set anOrder to item orderCount of orderData
	set orderNo to item orderCount of theOrderNos
	set progress additional description to "Checking Files on Order " & orderNo
	set mastersPath to folderPath of anOrder & "Masters/"
	tell script "Cloud Additions" to set theFiles to list_from_artDrive(mastersPath)
	copy {orderNo, customerName of anOrder, missing value, missing value, missing value, missing value, missing value, missing value} to end of chartData
	set rowCount to rowCount + 1
	copy rowCount to end of higlightedRows
	repeat with tabNo from 1 to (count of designs of anOrder)
		set aTab to item tabNo of designs of anOrder
		repeat with aPrintArea in printAreas of aTab
			set hasAFile to false
			set masterIdentifier to orderNo & "_" & |id| of aPrintArea
			if theFiles is not false then
				repeat with aFile in theFiles
					if aFile contains masterIdentifier then
						copy (mastersPath & aFile) to end of foundMasters
						set {delimitHolder, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "_"}
						set printMethodFromFilename to text item 3 of aFile
						set AppleScript's text item delimiters to delimitHolder
						set hasAFile to true
						exit repeat
					end if
				end repeat
			end if
			tell script "CRM_AND_ORDER_RELATED" to set productionMethod to manage_production_methods({functionType:"CONVERT", inputType:"ID", outputTypes:"ABBR", inputValue:(printMethodId of aPrintArea)})
			if productionMethod is "SP" then
				if hasAFile then
					if printMethodFromFilename contains "SP" then
						set productionMethod to printMethodFromFilename
					end if
				end if
			end if
			set thisRow to {orderNo, customerName of anOrder, tabNo as text, |description| of aPrintArea, productionMethod, |id| of aPrintArea as text, hasAFile, false}
			copy thisRow to end of chartData
			set rowCount to rowCount + 1
		end repeat
	end repeat
	copy {missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value} to end of chartData
	set rowCount to rowCount + 1
end repeat

set theHeadings to {"Order Number", "Customer Name", "Tab", "Print Area", "Print Method", "Print Area ID", "Existing File?", "Copy To Here"}

set printCopyTable to make new table with data chartData with title "Duplicate Master Files" column headings theHeadings with prompt "Click to select a row for the print area to copy from, and select checkboxes for other print areas to copy it to." editable columns {8} row template {"", "", "", "", "", "", true, true} without multiple selections allowed and row numbering
modify table printCopyTable highlighted rows higlightedRows grid style grid both dashed between rows OK button name "Submit For Processing"
set theResult to display table printCopyTable

set selectionToCopyFrom to item 1 of values selected of theResult
if item 8 of selectionToCopyFrom is true then display dialog "The print area you selected to copy FROM is ALSO one of the Print Areas you selected to copy TO. Try again and" & return & "BE MORE CAREFUL." buttons {"Cancel"} default button "Cancel"
set masterPrintMethodFromFilename to text item 5 of selectionToCopyFrom


set selectionsToCopyTo to {}
repeat with aRow in values returned of theResult
	if item 8 of aRow is true then copy contents of aRow to end of selectionsToCopyTo
end repeat

set fileToCopyIdentifier to item 1 of selectionToCopyFrom & "_" & item 6 of selectionToCopyFrom
set pathOfMasterToCopy to ""
repeat with aFile in foundMasters
	if aFile contains fileToCopyIdentifier then
		set pathOfMasterToCopy to aFile
		exit repeat
	end if
end repeat
if pathOfMasterToCopy is "" then display dialog "No Master file was found for the Master you selected to copy." buttons {"Cancel"} default button "Cancel"
tell script "GENERAL_PURPOSE"
	set masterName to get_filename_from_posix_path(pathOfMasterToCopy)
	set fileExtension to get_extension_from_filename(masterName)
end tell
set {delimitHolder, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
set theVolume to text item 2 of pathOfMasterToCopy
set AppleScript's text item delimiters to delimitHolder
set contractedArtPath to "/" & theVolume & "/Contracted Art/"

set fileCopyCount to count of selectionsToCopyTo
set progress total steps to fileCopyCount
set progress completed steps to 0
set progress additional description to "Copying " & fileCopyCount & " selected file to new print areas."

set displayWarning to false
set warningDialog to "You selected to copy the Master: " & return & masterName & return & return & "to " & fileCopyCount & " other Print Areas, but the following print areas you selected already have Master Files that will be overwritten."
repeat with aSelection in selectionsToCopyTo
	if item 7 of aSelection is true then
		if item 6 of aSelection is "" then display dialog "One of the print areas you selected to copy TO was a header row for an order or a blank row. That's not how this works, you can only copy a file to a Design Print Area. Try again and" & return & "BE MORE CAREFUL." with icon caution buttons {"Cancel"} default button "Cancel"
		
		set displayWarning to true
		set fileToReplaceIdentifier to item 1 of aSelection & "_" & item 6 of aSelection
		set pathOfExistingFile to ""
		repeat with aFile in foundMasters
			if aFile contains fileToReplaceIdentifier then
				set pathOfExistingFile to aFile
				exit repeat
			end if
		end repeat
		set warningDialog to warningDialog & return & return & pathOfExistingFile
	end if
end repeat
set warningDialog to warningDialog & return & return & "Are you sure you want to proceed?"

if displayWarning is true then display dialog warningDialog with icon caution buttons {"Yes, REPLACE them!", "Cancel"} default button "Cancel"

set finalDialogHeader to "Done!" & return & return
set copySuccessDialogText to "File " & masterName & return & "was successfully copied to:" & return
set copyProblemsDialogText to ""
set theIcon to "applet"

set fileConversionWarning to ""

repeat with aSelection in selectionsToCopyTo
	tell aSelection
		if my check_conversion_logic(masterPrintMethodFromFilename, item 5) then display dialog "You attempted to copy a file from the process:" & return & masterPrintMethodFromFilename & return & return & "To the process:" & return & item 5 & return & return & "But this requires converting the format of the file and can not be done automatically by this tool." with icon caution buttons {"Cancel"} default button "Cancel"
		
		if item 5 is "SP" then
			set printMethod to masterPrintMethodFromFilename
		else
			set printMethod to item 5
		end if
		set newFileName to item 3 & "_" & item 4 & "_" & printMethod & "_" & item 1 & "_" & item 6 & "." & fileExtension
	end tell
	set copyToPath to contractedArtPath & newFileName
	set progress completed steps to progress completed steps + 1
	set progress additional description to "Copying file:" & return & pathOfMasterToCopy & return & "to:" & return & copyToPath
	tell script "Cloud Additions" to set thisResult to move_on_artDrive({oldFilePath:pathOfMasterToCopy, newFilePath:copyToPath, operation:"COPY"})
	if thisResult is true then
		set copySuccessDialogText to copySuccessDialogText & newFileName & return
	else
		set theIcon to icon to caution
		set finalDialogHeader to "WARNING: COPY ISSUE"
		set copyProblemsDialogText to "File: " & newFileName & "was not copied to, this error was returned:" & return & thisResult & return & return
	end if
end repeat

display dialog copySuccessDialogText & copyProblemsDialogText & return & return & "It may take a little while for Artbot to process them before the files all show up." with title finalDialogHeader with icon theIcon

on check_conversion_logic(fromProcess, toProcess) -- returns true if there's a problem, false otherwise
	if fromProcess contains "SP" and toProcess does not contain "SP" then return true
	if toProcess contains "SP" and fromProcess does not contain "SP" then return true
	if fromProcess is "CUT" and toProcess is not "CUT" then return true
	if toProcess is "CUT" and fromProcess is not "CUT" then return true
	if (fromProcess is "EMB") or (fromProcess is "DTG") and toProcess is "HDD" then return true
	return false
end check_conversion_logic

You’re asking for trouble using Dropbox or similar with bundles like apps. They treat them as folders, which they are, but they have no concept of syncing them as a discrete unit – so they can sync individual files, and effectively invalidate bundles.

Ahhh, that makes sense.

What you just described probably is the cause of this, but I’m even more sure it’s the cause of us getting seemingly random Gatekeeper denials on our .apps on Dropbox, which are often fixed by simply overwriting with an identical copy.

Now what I’m going to do about it, I currently have no idea. Anybody know a syncing tool I could use to update my scripts to 60+ users as I revise them that does respect app bundles in a better way? I assume Google Drive or other Dropbox competitors will be just the same.

I also assume that if I write something that automates compressing the bundles (into a .zip or whatever) and deploying them via Dropbox but then expanding them into a user’s local Scripts folder should bypass this?

Maybe I can just attach a Folder Action Script to everyone’s Dropbox folder, and have the script note if a new .zip file was added, and if it was, expand it into their user scripts folder, replacing on conflicts?

Just brainstorming here, if anyone has any bright ideas.

Thanks!

Yep, even iCloud. Bundles and clouds don’t mix.