Changes to ActionUID?

I can't explain how this problem arose.

Until now, the ActionUIDs on my system were nine digits long, e.g., 101527380. Recently, they've become thirteen digits long, such as 1783609943456.

Since then, using a “selectAction UID” command with such long UIDs in AppleScript results in the “ERROR: an action ID must be supplied.”

What am I doing wrong?

Action IDs are 64 bit integers. My guess is they have got past some limit that AppleScript can't cope with.

Action IDs are allocated automatically, increasing from 0, but remembered, and thus new ones are always greater than all existing IDs.

They aren't really used for much of anything except AppleScript.

There is no automatic way of resetting them since basically 64 bit numbers are really really really big (20 digits long, roughly the number of atoms in the galaxy), so it should never be an issue.
However there is a mechanism for resetting them:

In the Terminal, run the command:

defaults write com.stairways.keyboardmaestro.editor ResetActionUIDs -bool YES

then relaunch the Keyboard Maestro editor.

That should resolve your problem.

Paste the following into Script Editor:

set x to 536870911
set y to 536870912

return "Class of x: " & class of x & return & "Class of y: " & class of y

...then select Script->Compile (or hit ⌘K) and you'll see:

Spot the change on line 2? And if you run the script the result is:

As @peternlewis says, your Action UIDs have gone past AS's integer limit, are being presented as reals, which breaks the call to selectAction because it requires an integer.

A UID reset is the easy solution -- but you probably could instead convert all your AppleScripts to JXA which (I think!) will let your UIDs go up to 9,007,199,254,740,991 (or even higher if BigInts are valid!).

Resetting the UIDs resolves the current issue. In my case, it was caused by importing a macro from another user.

However:
It doesn't solve the problem in AppleScript. I want to select an action. Is there another way to make it possible to call “selectAction UID” with large values?

Hmm. I'm not very familiar with JXA. Is there a way to select an action with a high UID?

Not past 32 (probably 31) bits, no. AppleScript does not appear to support integers larger than 32 bits.

You select Actions similarly to AS:

const actionUUID = 13892432;
const kmEditor = Application("Keyboard Maestro");

kmEditor.selectaction(actionUUID);

(@_jims -- honestly, it is selectaction, as shown in the Dictionary screenshot.)

...so find an Action with a too-big-for-AS UID and try it.

The point is that JXA allows much bigger integers than AS so you won't be hit by AS's silent coercion to reals. The downside is that you'll have to rewrite any AS that might use an ID greater than 536870911 to JXA...

I know very little JavaScript, but you should be able to find most of the info you need on the Forum (target posts by @ComplexPoint), the KM Wiki's JavaScript for Automation page, and from playing in Script Editor with both the script and the KM Dictionary set to "JavaScript"

Oops, I meant well, but screwed up. I should have known better. Please accept my apology, @Nige_S.

(The irony of this is that I’ve spent some significant time recently learning JXA. :thinking:)

@peternlewis I've been seeing this recently too. Coincidental or could there be something related to Golden Gate?

• Keyboard Maestro 11.1.1
• Golden Gate 27.0.1 (26A434)/MacBookPro18,2

@Nige_S, I tried your suggested JXA approach; unfortunately that didn't work either:

2026-10-10 09:48:38 Action 1783609957091 failed: Execute a JavaScript For Automation failed with script error: text-script: execution error: Error: Error: an action ID must be supplied (-1)

I assume you mean 32-bit.

I'm wondering, though, how someone could have ended up with a UID with the value 1,783,609,943,456 this way (automatic increment),

I can only imagine that a user created such an entry via XML.

I do not. I mean 64 bit integers. That is why AppleScript is having a problem as it only supports 32 bit numbers.

You would get an ID of 1,783,609,943,456 if there existed an ID of 1,783,609,943,455.

I would have to assume the sequence was something like:

Someone either accidentally created XML with very large action IDs

or

Someone did some automated process that added and removed actions at high speed. Although even then it would seem likely that it would take a very long time to get to such a large number.

Anyway, then the macro was exported and imported elsewhere.

In any event, that number is actually a tiny number in the 64-bit integer space (something like 0.000001% of the limit). So as far as Keyboard Maestro is concerned it is a perfectly fine number of no particular note.