jely2002/youtube-dl-gui · info
Unknown shortcut action
Error message
Unknown shortcut action: ${event.payload.action} What it means
registerShortcutListeners subscribes to a Tauri shortcut event and dispatches each payload's action to the matching store call via a switch. Unknown action strings fall into the default case, logging 'Unknown shortcut action: ${event.payload.action}' with console.warn — no exception is raised, and other shortcuts keep working.
Solutions
- Compare the action string in the warning against the switch cases in shortcuts.ts and add/rename the missing case.
- Keep the Rust shortcut registrations and the TS switch in one synchronized list (shared constant or codegen).
- Update frontend and backend together when adding shortcut actions so both deploy in the same release.
- Ignore the warning for third-party/unrecognized actions if the handler should be forward-compatible.
Example fix
// before
case 'download_all': { ... break; }
default: { console.warn(`Unknown shortcut action: ${event.payload.action}`); }
// after
case 'download_all': { ... break; }
case 'newly_added_action': { ... break; } // sync with Rust registration
default: { console.warn(`Unknown shortcut action: ${event.payload.action}`); } Defensive patterns
Strategy: validation
Validate before calling
const KNOWN_ACTIONS = ['pause_all', 'download_all'] as const; type ShortcutAction = typeof KNOWN_ACTIONS[number]; const isKnownAction = (a: string): a is ShortcutAction => (KNOWN_ACTIONS as readonly string[]).includes(a);
Type guard
const isShortcutAction = (a: string): a is ShortcutAction => (KNOWN_ACTIONS as readonly string[]).includes(a);
Try / catch
const action = event.payload.action;
if (!isKnownAction(action)) {
console.warn(`Unknown shortcut action: ${action}`);
return; // forward-compatible: ignore future actions
} Prevention
- Keep the Rust shortcut registrations and the TS switch cases in one synchronized constant list.
- Ship backend and frontend shortcut changes in the same release.
- Add a unit test asserting every registered backend action has a handler case.
When it happens
Trigger: A global shortcut event arrives whose payload.action is not one of the handled cases — the Rust side registered a new/renamed action the TS handler does not know, a typo in the action string, or stale frontend code after a backend update.
Common situations: Backend and frontend updated out of sync (added a shortcut action in Rust but not in the TS switch); plugin update changing action names; custom user shortcut config emitting an unsupported action.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Orphaned media item found during error handling.
- Failed to retrieve stronghold status
- Failed to initialize stronghold
- Unable to retrieve platform from Rust.
- No options found for group
AI-assisted analysis of jely2002/youtube-dl-gui@c402ee39c0 (2026-09-12).
Data as JSON: /api/errors/fed881fa8c7d9a75.
Report an issue: GitHub.
Appendix: source
Thrown at src/tauri/listeners/shortcuts.ts:33
return;
}
await mediaStore.dispatchMediaInfoFetch(url, true);
break;
}
case 'media_add_and_download': {
const url = await readText();
if (!isValidUrl(url)) {
return;
}
await mediaStore.addAndDownload(url, true);
break;
}
case 'download_all': {
await mediaStore.downloadAllGroups(true);
break;
}
default: {
console.warn(`Unknown shortcut action: ${event.payload.action}`);
}
}
});
}
View on GitHub (pinned to c402ee39c0)