.pkg installation failing with "Not authorized to send Apple events to Finder" error in preinstall phase

I have a macOS package (.pkg) that checks for installed Java versions on the machine during the preinstall phase using a preinstall script. If the required Java version is not found, the script displays a message using osascript as shown below.

/usr/bin/osascript -e 'tell application "Finder"' -e 'activate' -e 'display dialog "Java Development Kit (JDK) 11 is required" buttons{"OK"} with title "Myprod Warning"' -e 'end tell'

So far, no issues have been observed with the installation of my package on all versions of macOS. However, on macOS 15.2, the installation is failing with a "Not authorized to send Apple events to Finder" error.

Could someone please help me understand what might be causing this issue and how to resolve it?

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. Please file a bug report, include a copy of your script and the error with directions for reproducing the error, and post the FB number here once you do.

Bug Reporting: How and Why? has tips on creating your bug report.

.pkg installation failing with "Not authorized to send Apple events to Finder" error in preinstall phase
 
 
Q