{"record":{"id":"262375cf944e8376","repo":"Molunerfinn/PicGo","slug":"shortcut-not-found-shortcutid","errorCode":null,"errorMessage":"Shortcut not found: ${shortcutId}","messagePattern":"Shortcut not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/store/settings/actions.ts","lineNumber":111,"sourceCode":"    })\n\n    useAppStore.setState((state) => {\n      if (!state.appConfig) {\n        return\n      }\n\n      state.appConfig.picBed.proxy = proxy\n    })\n  },\n  async updateShortcutKeys (shortcutId: string, keys: string[]) {\n    await appActions.ensureSettingsHydrated()\n    const currentShortKey =\n      useAppStore.getState().appConfig?.settings.shortKey ??\n      defaultSettingsConfig.shortKey\n    const targetShortcut = currentShortKey[shortcutId]\n\n    if (!targetShortcut) {\n      throw new Error(`Shortcut not found: ${shortcutId}`)\n    }\n\n    const nextKey = keys.join('+')\n    const [from = 'picgo'] = shortcutId.split(':')\n    const didUpdate = await settingsAdapter.updateShortcut({\n      enable: targetShortcut.enable,\n      key: nextKey,\n      label: targetShortcut.label,\n      name: targetShortcut.name,\n      from\n    }, targetShortcut.key)\n\n    if (!didUpdate) {\n      throw new Error(`Failed to update shortcut: ${shortcutId}`)\n    }\n\n    updateSettingsState({\n      shortKey: {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/Molunerfinn/PicGo/blob/07ec7068a5512344da093d49a8408fa63ba3421e/src/renderer/store/settings/actions.ts#L93-L129","documentation":"updateShortcutKeys reads appConfig.settings.shortKey and throws this templated error when no shortcut exists under the given shortcutId. The action needs the existing shortcut's enable state, key, label and name to build the update payload for settingsAdapter.updateShortcut, so an unknown id is rejected before any IPC call.","triggerScenarios":"Calling updateShortcutKeys(shortcutId, keys) with an id not present in shortKey (typo, renamed id, or shortcut map not yet loaded from appConfig so the code fell back to defaultSettingsConfig.shortKey which lacks the id).","commonSituations":"Shortcut ids changed between app versions; calling before settings are hydrated (appConfig still undefined, default map used); hardcoding an id like 'picgo:upload' that no longer exists.","solutions":["Wait for appConfig hydration and enumerate the actual shortcut ids from appConfig.settings.shortKey before updating.","Validate shortcutId against Object.keys(currentShortKey) in the caller before invoking the action.","Update the shortcut id to the current version's id (check the shortcut settings UI or constants).","Initialize missing shortcuts into defaultSettingsConfig.shortKey if the id is legitimately new."],"exampleFix":"// before\nawait settingsStoreActions.updateShortcutKeys(shortcutId, keys)\n\n// after\nconst shortKey = useAppStore.getState().appConfig?.settings.shortKey\nif (!shortKey?.[shortcutId]) {\n  toast.warning(`Unknown shortcut: ${shortcutId}`)\n  return\n}\nawait settingsStoreActions.updateShortcutKeys(shortcutId, keys)","handlingStrategy":"validation","validationCode":"const shortKey = useAppStore.getState().appConfig?.settings.shortKey\n  ?? defaultSettingsConfig.shortKey\nif (!(shortcutId in shortKey)) {\n  // unknown shortcut id — abort before update\n  return\n}","typeGuard":"function isKnownShortcut(\n  shortKey: Record<string, IShortKeyConfig>,\n  shortcutId: string\n): shortcutId is string & keyof typeof shortKey {\n  return Object.prototype.hasOwnProperty.call(shortKey, shortcutId)\n}","tryCatchPattern":"try {\n  await settingsStoreActions.updateShortcutKeys(shortcutId, keys)\n} catch (err) {\n  if ((err as Error).message.startsWith('Shortcut not found')) {\n    toast.warning(`Unknown shortcut: ${shortcutId}`)\n  }\n}","preventionTips":["Wait for appConfig hydration before any shortcut mutation.","Enumerate ids with Object.keys(shortKey) to build UI lists — never hardcode ids.","Re-validate persisted shortcut ids after app upgrades.","Keep the fallback defaultSettingsConfig.shortKey in sync with real ids."],"tags":["shortcut","settings","hotkey","validation"],"backgroundTag":"shortcut-id-not-found","analyzedSha":"07ec7068a5512344da093d49a8408fa63ba3421e","analyzedAt":"2026-08-30T01:45:22.289Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}