Finder executes command but still throws an error?

Another day, another inexplicable applescripting problem :confused:

So I have this one liner to create a new folder. When I run this script, the new folder IS created!
And yet, the script gets an error -10000 “Finder got an error: AppleEvent handler failed.”

tell application "Finder"
	make new folder at (tdalias of TargetDisk) with properties {name:"stress_test"}
end tell

Note that (tdalias of TargetDisk) is just an alias of an external hard drive.

This DOES create the folder. So what is the error? What is causing it? There is nothing after this, this is the end of the script.

UPDATE:
looks like the problem was that the variable I thought was an alias, was actually a string. So the error went away with a key “as alias”.

BUT that said, I’m not sure how it was still able to create the folder in the first place with no proper path.

Seems odd but presumably related to the file not actually being a folder.

You could try using the original item property of the alias.

tell application "Finder"
	set tdOriginalItem to original item of tdalias of TargetDisk
	make new folder at tdOriginalItem with properties {name:"stress_test"}
end tell

You should be able to consolidate into a single line:

make new folder at (get original item of tdalias of TargetDisk) ¬
with properties {name:"stress_test"}

It seems that the get is obligatory.

By the way, if you use a symbolic link to ‘TargetDisk’ instead of an alias then it would likely work without error. It does on my system, at any rate.