%FrontBrowserURL% token fails on macOS 26 (Tahoe) – AppleScript works

Hi Peter,

I'm running into an issue with the %FrontBrowserURL% token (and presumably related front-browser tokens) on macOS 26.4 and 26.4.1 (did not try before on older releases):

Setup:

  • macOS 26.4.1, MacBook Pro M5

  • Keyboard Maestro 11.0.4

  • Safari (also tested with Chrome Canary)

Symptom: When a macro uses %FrontBrowserURL%, I get the following error notification:

Set Variable to Front Browser Field failed to get value of field %FrontBrowserURL% in macro "…" (while executing Set Variable "local_URL" to Front Browser Field "%FrontBrowserURL%")

What I've already tried (no effect):

  • Safari → Developer Settings → "Allow remote automation" and "Allow JavaScript from Apple Events" are both enabled

  • Keyboard Maestro has Safari automation permission in System Settings → Privacy & Security → Automation

  • sudo tccutil reset AppleEvents + restart of Keyboard Maestro Engine

  • Reinstalled Keyboard Maestro over the existing install

  • codesign --verify passes for both the app itself and the Engine

  • Error occurred first on 26.4, later updated macOS to 26.4.1

What works: An Execute AppleScript action with:

tell application "Safari"
    return URL of front document
end tell

returns the URL reliably. So AppleScript access to Safari itself is fine — the issue seems to be specific to how the %FrontBrowserURL% token resolves internally on macOS 26.

Notably, KM Engine never appears in the Automation permissions list in System Settings, only "Keyboard Maestro" itself does. No permission prompt for the Engine ever triggers, even after a full TCC reset.

Happy to provide more diagnostics if useful.

Thanks for KM — it's an indispensable tool.

Best, Martin

It works fine here on the same OS. What appears in the Accessibility section of Privacy & Security? Both the engine and the app need to be there.

-rob.

Thanks for your quick response!

In “Accessibility”, there are both, KM and the engine. In “Automation”, just KM, not the engine.

Weird is, that the macro works accessing Safari using AppleScript, that should be the same security context as far as I understand?

Automation is fine, at least it matches my setup. No idea why it's not working for you. You might try an Accessibility reset, though those are a royal PitA to set up everything again.

-rob.

Have you checked the Security preferences in Keyboard Maestro, it can run a test of controlling a web browser.

Does the %SafariURL% token work?

Do other web browser tokens/actions work?

@peternlewis

%SafariURL% is also not working. %ChromeURL% also not (might be a Chrome Canary thing, though).

The test works for Safari, not for Chrome (Canary).

Chrome Canary is not important for my daily life, I use Safari most of the time. Just tested it with another browser.

The SafariURL token is basically just an AppleScript with some fluff and something like:

tell application "Safari" to tell document 1 to URL

Does that AppleScript work from Script Editor?

Does it work from Execute an AppleScript action? Make sure the action is configured to report errors and make sure Notifications are enabled for the Keyboard Maestro Engine and/or check the Engine.log file.

Yes works both ways.

Just updated to 26.4.1 to test, and the %SafariURL% Text Token is working here -- so it isn't a general problem.

Try

defaults read com.stairways.keyboardmaestro.engine AppleScriptSafariBundleID

...in Terminal, to make sure you haven't told KM to use Tech Preview or similar for Safari-targeting tokens -- you should get

The domain/default pair of (com.stairways.keyboardmaestro.engine, AppleScriptSafariBundleID) does not exist

...unless you've changed it.

1 Like

Do they both execute instantly? There is a limit on token response time of 0.9 seconds.

At this point, I would consider just restarting your Mac (especially if you upgraded recently as I always recommend restarting after an upgrade). It may be there is some sort of weird issue going on that is pointless to try to debug.

Other than that, there are debug flags you could turn on the see the AppleScript being executed in the log and perhaps that would indicate the issue.

Both have no noticeable delay.

Restarting my Mac, uff :slight_smile: Kidding, just did it, same.

On a quick google search, I did not find any way to enable debug flags.

That’s set as supposed to be:

\~/z/I/i/c/configs ❱ defaults read com.stairways.keyboardmaestro.engine AppleScriptSafariBundleID
2026-05-05 10:17:48.051 defaults\[70348:5288238\]
The domain/default pair of (com.stairways.keyboardmaestro.engine, AppleScriptSafariBundleID) does not exist

In the Terminal, run the command:

defaults write com.stairways.keyboardmaestro.engine Debug WebBrowserAction

then relaunch the Keyboard Maestro Engine (in the editor, File ➤ Quit Engine, Launch Engine).

then run the command:

tail -f ~/Library/Logs/'Keyboard Maestro'/Engine.log

And that will show you the AppleScript used by the engine when resolving the tokens.

Here you go:

~/D/F/i/H/V/M/_final ❱ tail -f ~/Library/Logs/'Keyboard Maestro'/Engine.log
2026-06-09 20:03:50 Engine Quitting
2026-06-09 20:10:07 Engine Starting 11.0.4
2026-06-09 20:10:07 Old engine details remains a running process Running Engine Details/1250
2026-06-09 20:10:08 Invalid Plug In Action with Name Snap Palette to Front Window
Last message repeated 18 times
2026-06-09 20:24:57 Engine Quitting
2026-06-09 20:25:00 Debugging level set to ' WebBrowserAction '
2026-06-09 20:25:00 Engine Starting 11.0.4
2026-06-09 20:25:01 Old engine details remains a running process Running Engine Details/1250
2026-06-09 20:25:01 Invalid Plug In Action with Name Snap Palette to Front Window






Last message repeated 12 times
2026-06-09 20:25:30 Execute macro “email addy” from trigger The Hot Key ⌥⇧M is pressed
2026-06-09 20:25:39 script is [tell application id "com.apple.Safari"
 if it is running then
 tell document 1
 URL
 end tell
 else
 "Not Running"
 end if

 end tell
]
2026-06-09 20:25:39 script is [tell application id "com.apple.Safari"
 if it is running then
 tell document 1


			set r to do JavaScript "'GOOD:' + https://forum.keyboardmaestro.com/t/frontbrowserurl-token-fails-on-macos-26-tahoe-applescript-works/51466/9.value"
			try
				if r is missing value then
					set r to ""
				end if
			on error errMsg
				set r to ""
			end try


 end tell
 else


			set r to "Not Running"


 end if
 r

 end tell
]
2026-06-09 20:25:39 Action 15859862 failed: Set Variable to Front Browser Field failed to get value of field %SafariURL%
2026-06-09 20:25:39 Set Variable to Front Browser Field failed to get value of field %SafariURL% in macro “email addy” (while executing Set Variable “local_URL” to Front Browser Field “%SafariURL%”).
2026-06-09 20:25:42 Action 15859863 failed: Search Regular Expression failed to match ^http?://(?:[a-zA-Z0-9.-_]+\.)([a-z0-9-_]+)\.([a-z]+)/?
2026-06-09 20:25:42 Search Regular Expression failed to match ^http?://(?:[a-zA-Z0-9.-_]+\.)([a-z0-9-_]+)\.([a-z]+)/?. Macro “email addy” cancelled (while executing Search Environment Variable “local_url” Using Regular Expression (ignoring case)).

Are you sure you're using the right Action?

The log says

2026-06-09 20:25:39 Action 15859862 failed: Set Variable to Front Browser Field failed to get value of field %SafariURL%
                                            -----------------------------------

...and I've underscored the Action name.

Unless you've manually renamed the Action, you're using the wrong one -- you can't evaluate the %SafariURL% text token in that Action's text field, and if you could the derived field would almost certainly not exist.

You just need the normal "Set Variable" Action, using the text token:

Apologies if this is the solution -- the same wrong Action is mentioned in your OP, and I completely missed it!

1 Like

You’re right, it works with the “Set Variable” action…

Thank’s a lot!

It looks like the next thing your macro does is extract parts of the URL. If you don't want the complete URL you can skip the "out it in a variable" step, because "Search using Regular Expression" can use the Token:

Also, I think your regex is wrong. You start with ^http?:// -- "a string that starts with h then t then t and then an optional p. I suspect you definitely want the p but an optional s, so: ^https?://

It may, depending on what you are doing, be logically wrong too. You seem to be extracting the top-level and second-level domains from the URL. Meaningful for something like www.google.com, but less useful for www.bbc.co.uk and similar!