Strange behaviour with Finder container items: please help!

This is really weird. I have a folder action script that has been running for a long time (as in days/weeks) without being changed and it has run many times successfully. All of a sudden today it is throwing an error. And while I’ve narrowed down what is throwing an error it’s very strange that it has been running fine until now. I have not updated the OS or done anything else that would explain the issue.

I can reproduce the error in a sample script as follows:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set f to choose file
tell application "Finder" to reveal the container of f

When I run that in Script Debugger I get the following error:

Finder got an error: Can’t get alias “Macintosh HD:[PATH_TO_F]”.

My folder action script performs an action on a file that is located by reference to the location of the file that is passed to the folder action handler. That is, I get the container of the container of the file that is passed to the handler, convert it to text, append the other file name, and convert it to an alias.

It is throwing the following error: Error Can’t make «class ctnr» of alias “Macintosh HD:[PATH_TO_FOLDER]” into type text.

It definitely seems like an error related to the class ctnr which I assume is Finder’s container item class.

The above sample script which tells Finder to reveal the container works fine if you just tell it to reveal the file. But if you tell it to reveal the container then it throws an error, but the error says that it can’t find the file (and doesn’t reference the container).

And all of this is extra strange because until yesterday this was working perfectly. :confused:

Can anyone else reproduce the issue from the above sample code or offer any other insight?

macOS 10.14.6

First thing: Have you tried a restart?

Yes, I have. Just now. And it has fixed the issue. embarrassed face

Sorry, I just had so many apps and windows open including unsaved tabs in Script Debugger and Script Debugger doesn’t seem to like me quitting/restarting with unsaved/untitled documents so I was reluctant to restart. And seems like such a weird thing to be effected by save state.

Anyway, out of curiosity now rather than desperation, any ideas what the issue could have been?

Not really. I oniy suggested a restart because it fixed an odd issue here the other day, after I’d spent a couple of hours trying all sorts of other things.

I hate having to restart, and it’s almost always a last resort, but restarting has also cleared up several puzzling errors for me lately.