I can echo this behavior.
In Sequoia, this worked fine, regardless of whether the current track was added to the library or not. In Tahoe 26.0.0 public release, this doesn't work any more. If the track is in the library, it works, if not, it returns an error. I haven't tried the 26.0.1 release yet, since it didn't specfically note a fix for this in the release notes, as brief as they were.
I was using this script to provide shortcut keys for the "favorite" and "suggest less" actions in Music. Both stopped working in Tahoe if the track was not added to the library, which is the majority of the time when playing a user's personal station.
Favorite
tell application "Music"
set favorited of current track to true
set disliked of current track to false
end tell
Suggest Less
tell application "Music"
set favorited of current track to false
set disliked of current track to true
next track
end tell
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags: