{"record":{"id":"c49a84149cbc45a6","repo":"libnyanpasu/clash-nyanpasu","slug":"hotkey-error-missing-super-key","errorCode":null,"errorMessage":"hotkey_error.missing_super_key","messagePattern":"hotkey_error\\.missing_super_key","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/tauri/src/core/hotkey.rs","lineNumber":238,"sourceCode":"                    }\n                }\n            }\n            *self.current.lock() = hotkeys;\n        }\n\n        Ok(())\n    }\n\n    /// 检查一个键是否合法\n    fn check_key(hotkey: &str) -> anyhow::Result<()> {\n        // fix #287\n        // tauri的这几个方法全部有Result expect，会panic，先检测一遍避免挂了\n        if hotkey.parse::<Shortcut>().is_err() {\n            bail!(\"{}\", t!(\"hotkey_error.invalid_hotkey\", hotkey = hotkey));\n        }\n        // Validate super key requirement\n        if !Self::validate_super_key(hotkey) {\n            bail!(\"{}\", t!(\"hotkey_error.missing_super_key\"));\n        }\n        Ok(())\n    }\n\n    /// Check if the hotkey contains a super key modifier (case-insensitive)\n    pub fn validate_super_key(hotkey: &str) -> bool {\n        let hotkey_lower = hotkey.to_lowercase();\n        SUPER_KEYS\n            .iter()\n            .any(|key| hotkey_lower.contains(&key.to_lowercase()))\n    }\n\n    fn register(&self, hotkey: &str, func: &str) -> Result<()> {\n        let app_handle = self.app_handle.lock();\n        if app_handle.is_none() {\n            bail!(\"app handle is none\");\n        }\n        let manager = app_handle.as_ref().unwrap().global_shortcut();","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/core/hotkey.rs#L220-L256","documentation":"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.","triggerScenarios":"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).","commonSituations":"Users configuring plain modifier combos; configs imported from other apps without this policy; frontend pickers that don't enforce the super-key requirement.","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"],"exampleFix":"// before\n\"Ctrl+Alt+P\": \"toggle_system_proxy\"\n// after\n\"Super+Ctrl+Alt+P\": \"toggle_system_proxy\"","handlingStrategy":"validation","validationCode":"fn has_super_key(hotkey: &str) -> bool {\n    hotkey.to_lowercase().split('+').any(|p| p == \"super\" || p == \"meta\" || p == \"cmd\" || p == \"win\")\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = hotkey_manager.register(k, f) {\n    ui.show_warning(t!(\"hotkey_error.missing_super_key\"));\n}","preventionTips":["Enforce the super-modifier requirement in the hotkey picker UI","Document the hotkey policy for users importing configs"],"tags":["hotkey","validation","policy"],"backgroundTag":"invalid-config-value","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}