Molunerfinn/PicGo · error

Failed to change current uploader

Error message

Failed to change current uploader

What it means

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.

Source

Thrown at src/renderer/adapters/providers.ts:16

import { toast } from 'sonner'
import { GET_PICBED_CONFIG } from '#/events/constants'
import { IRPCActionType } from '~/universal/types/enum'
import { invokeRPC, sendToMain } from '@/utils/dataSender'
import { ipc } from '@/utils/bridge'

export interface ProviderSchemaResult {
  config: IPicGoPluginConfig[]
  name: string
}

export const providersAdapter = {
  async changeCurrentUploader (type: string, configName?: string) {
    const result = await invokeRPC<string>(IRPCActionType.CHANGE_CURRENT_UPLOADER, type, configName)
    if (!result.success) {
      throw new Error(result.error || 'Failed to change current uploader')
    }
    return result.data
  },
  async getProviderConfigList (type: string) {
    const result = await invokeRPC<IUploaderConfigItem>(IRPCActionType.GET_PICBED_CONFIG_LIST, type)
    if (!result.success) {
      throw new Error(result.error || 'Failed to load provider configs')
    }

    return result.data
  },
  async selectProviderConfig (type: string, configName: string) {
    const result = await invokeRPC<string>(IRPCActionType.SELECT_UPLOADER, type, configName)
    if (!result.success) {
      throw new Error(result.error || 'Failed to select provider config')
    }

    return result.data

View on GitHub (pinned to 07ec7068a5)

Solutions

  1. Inspect result.error/logs for the main-process reason
  2. Create/save a config for the target uploader type before switching to it
  3. Re-fetch the config list and pass a valid existing configName (or omit it to use the active one)
  4. Verify the `type` string matches a registered uploader exactly

Example fix

// before
await changeCurrentUploader('smms') // type not configured -> success:false
// after
const list = await getProviderConfigList('smms')
if (list.length > 0) {
  await changeCurrentUploader('smms', list[0]._configName)
}
Defensive patterns

Strategy: try-catch

Validate before calling

const list = await getProviderConfigList(type)
if (!list || list.length === 0) {
  throw new Error(`Uploader "${type}" has no config; configure it before switching`)
}

Type guard

function canSwitch(result) {
  return !!result && result.success === true
}

Try / catch

try {
  await changeCurrentUploader(type, configName)
} catch (e) {
  logger.error('uploader switch failed', e)
  notify('Keep current uploader; configure the target first')
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of Molunerfinn/PicGo@07ec7068a5 (2026-08-30). Data as JSON: /api/errors/033cd4694ff25c29. Report an issue: GitHub.