libnyanpasu/clash-nyanpasu · error
hotkey_error.missing_super_key
Error message
hotkey_error.missing_super_key
What it means
After the Shortcut parse succeeds, check_key additionally requires the hotkey to contain a super-key modifier (validate_super_key, case-insensitive check); if absent it bails with the localized hotkey_error.missing_super_key. This project policy forces system-level hotkeys to include a super/meta modifier to reduce accidental conflicts with normal application shortcuts.
Source
Thrown at backend/tauri/src/core/hotkey.rs:238
}
}
}
*self.current.lock() = hotkeys;
}
Ok(())
}
/// 检查一个键是否合法
fn check_key(hotkey: &str) -> anyhow::Result<()> {
// fix #287
// tauri的这几个方法全部有Result expect,会panic,先检测一遍避免挂了
if hotkey.parse::<Shortcut>().is_err() {
bail!("{}", t!("hotkey_error.invalid_hotkey", hotkey = hotkey));
}
// Validate super key requirement
if !Self::validate_super_key(hotkey) {
bail!("{}", t!("hotkey_error.missing_super_key"));
}
Ok(())
}
/// Check if the hotkey contains a super key modifier (case-insensitive)
pub fn validate_super_key(hotkey: &str) -> bool {
let hotkey_lower = hotkey.to_lowercase();
SUPER_KEYS
.iter()
.any(|key| hotkey_lower.contains(&key.to_lowercase()))
}
fn register(&self, hotkey: &str, func: &str) -> Result<()> {
let app_handle = self.app_handle.lock();
if app_handle.is_none() {
bail!("app handle is none");
}
let manager = app_handle.as_ref().unwrap().global_shortcut();View on GitHub (pinned to f7dbce2997)
Solutions
- Add the required super modifier to the hotkey (e.g. 'Super+Ctrl+Alt+P') and re-save
- Surface the localized missing_super_key message in the UI when the user saves a non-super hotkey
- If the policy is undesirable, adjust validate_super_key / check_key to accept other secure modifier combos
Example fix
// before "Ctrl+Alt+P": "toggle_system_proxy" // after "Super+Ctrl+Alt+P": "toggle_system_proxy"
Defensive patterns
Strategy: validation
Validate before calling
fn has_super_key(hotkey: &str) -> bool {
hotkey.to_lowercase().split('+').any(|p| p == "super" || p == "meta" || p == "cmd" || p == "win")
} Try / catch
if let Err(e) = hotkey_manager.register(k, f) {
ui.show_warning(t!("hotkey_error.missing_super_key"));
} Prevention
- Enforce the super-modifier requirement in the hotkey picker UI
- Document the hotkey policy for users importing configs
When it happens
Trigger: Registering a hotkey like 'Ctrl+Alt+P' or 'F9' that parses fine but lacks the required super key (e.g. Super/Meta/Win modifier per validate_super_key's accepted set).
Common situations: Users configuring plain modifier combos; configs imported from other apps without this policy; frontend pickers that don't enforce the super-key requirement.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- hotkey_error.invalid_hotkey
- Invalid theme color: {}
- invalid hotkey function: {s}
- app handle is none
- Invalid theme color: {}
AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08).
Data as JSON: /api/errors/c49a84149cbc45a6.
Report an issue: GitHub.