{"record":{"id":"033cd4694ff25c29","repo":"Molunerfinn/PicGo","slug":"failed-to-change-current-uploader","errorCode":null,"errorMessage":"Failed to change current uploader","messagePattern":"Failed to change current uploader","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/renderer/adapters/providers.ts","lineNumber":16,"sourceCode":"import { toast } from 'sonner'\nimport { GET_PICBED_CONFIG } from '#/events/constants'\nimport { IRPCActionType } from '~/universal/types/enum'\nimport { invokeRPC, sendToMain } from '@/utils/dataSender'\nimport { ipc } from '@/utils/bridge'\n\nexport interface ProviderSchemaResult {\n  config: IPicGoPluginConfig[]\n  name: string\n}\n\nexport const providersAdapter = {\n  async changeCurrentUploader (type: string, configName?: string) {\n    const result = await invokeRPC<string>(IRPCActionType.CHANGE_CURRENT_UPLOADER, type, configName)\n    if (!result.success) {\n      throw new Error(result.error || 'Failed to change current uploader')\n    }\n    return result.data\n  },\n  async getProviderConfigList (type: string) {\n    const result = await invokeRPC<IUploaderConfigItem>(IRPCActionType.GET_PICBED_CONFIG_LIST, type)\n    if (!result.success) {\n      throw new Error(result.error || 'Failed to load provider configs')\n    }\n\n    return result.data\n  },\n  async selectProviderConfig (type: string, configName: string) {\n    const result = await invokeRPC<string>(IRPCActionType.SELECT_UPLOADER, type, configName)\n    if (!result.success) {\n      throw new Error(result.error || 'Failed to select provider config')\n    }\n\n    return result.data","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/Molunerfinn/PicGo/blob/07ec7068a5512344da093d49a8408fa63ba3421e/src/renderer/adapters/providers.ts#L1-L34","documentation":"changeCurrentUploader invokes the CHANGE_CURRENT_UPLOADER RPC and throws when result.success is false, using result.error or the default 'Failed to change current uploader'. The main process rejected the switch — commonly because the target uploader type has no valid config or the active-config update failed while persisting.","triggerScenarios":"Calling providersAdapter.changeCurrentUploader(type, configName) where `type` has no saved configs, configName doesn't exist for that type, or the main handler threw while writing picBed.current / activator state.","commonSituations":"Selecting an uploader in settings before configuring it; configName from a stale list after deletion; config file write failure (permissions, read-only disk); type string mismatch (e.g. 'github' vs 'gitee' typo).","solutions":["Inspect result.error/logs for the main-process reason","Create/save a config for the target uploader type before switching to it","Re-fetch the config list and pass a valid existing configName (or omit it to use the active one)","Verify the `type` string matches a registered uploader exactly"],"exampleFix":"// before\nawait changeCurrentUploader('smms') // type not configured -> success:false\n// after\nconst list = await getProviderConfigList('smms')\nif (list.length > 0) {\n  await changeCurrentUploader('smms', list[0]._configName)\n}","handlingStrategy":"try-catch","validationCode":"const list = await getProviderConfigList(type)\nif (!list || list.length === 0) {\n  throw new Error(`Uploader \"${type}\" has no config; configure it before switching`)\n}","typeGuard":"function canSwitch(result) {\n  return !!result && result.success === true\n}","tryCatchPattern":"try {\n  await changeCurrentUploader(type, configName)\n} catch (e) {\n  logger.error('uploader switch failed', e)\n  notify('Keep current uploader; configure the target first')\n}","preventionTips":["Ensure the target uploader type has at least one saved config before switching","Pass a configName that exists in the current config list (refresh it first)","Verify exact uploader type strings against registered uploaders","Check config file writability if switches fail intermittently"],"tags":["uploader","rpc","config","switch-failed"],"backgroundTag":"uploader-switch-failed","analyzedSha":"07ec7068a5512344da093d49a8408fa63ba3421e","analyzedAt":"2026-08-30T01:45:22.289Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}