Molunerfinn/PicGo · error

Failed to copy provider config

Error message

Failed to copy provider config

What it means

copyProviderConfig sends IRPCActionType.COPY_UPLOADER_CONFIG to duplicate an existing uploader config under a new name and throws when the RPC fails. The main handler (src/main/events/rpc/routes/config.ts:72) calls picgo.uploaderConfig.copy(type, configName, newConfigName), which throws when the source config does not exist or the target name already exists. The renderer wraps that failure into this generic error.

Source

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

    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
  },
  async deleteProviderConfig (type: string, configName: string) {
    const result = await invokeRPC<IUploaderConfigItem>(IRPCActionType.DELETE_PICBED_CONFIG, type, configName)
    if (!result.success) {
      throw new Error(result.error || 'Failed to delete provider config')
    }

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

    return result.data
  },
  async saveProviderConfig (type: string, configId: string, values: IStringKeyMap) {
    const result = await invokeRPC<boolean>(IRPCActionType.UPDATE_UPLOADER_CONFIG, type, configId, values)
    if (!result.success) {
      throw new Error(result.error || 'Failed to save provider config')
    }

    if (result.data !== true) {
      throw new Error('Failed to save provider config')
    }
  },
  getProviderSchema (type: string): Promise<ProviderSchemaResult> {
    return new Promise((resolve, reject) => {
      const cleanup = ipc.once(GET_PICBED_CONFIG, (config: IPicGoPluginConfig[], name: string) => {
        resolve({ config, name })

View on GitHub (pinned to 07ec7068a5)

Solutions

  1. Pick a newConfigName that does not already exist in the type's config list
  2. Refresh the config list and verify the source configName still exists before copying
  3. Trim/normalize the new name to avoid whitespace-only collisions
  4. Inspect result.error for the main-process message (name exists / source not found)

Example fix

// before
await copyProviderConfig(type, src, newName)
// after
const { configList } = await getProviderConfigList(type)
if (!configList.some(c => c._configName === newName)) await copyProviderConfig(type, src, newName.trim())
Defensive patterns

Strategy: validation

Validate before calling

const { configList } = await getProviderConfigList(type)
if (!configList.some(c => c._configName === configName)) throw new Error('source config not found')
if (configList.some(c => c._configName === newConfigName)) throw new Error('target name already exists')

Type guard

function canCopy(list: IUploaderConfigItem[], src: string, dest: string): boolean { return list.some(c => c._configName === src) && !list.some(c => c._configName === dest) }

Try / catch

try {
  await copyProviderConfig(type, configName, newConfigName)
} catch (e) {
  showNotification((e as Error).message || $T('TIPS_COPY_CONFIG_FAILED'))
  await refreshConfigList(type)
}

Prevention

When it happens

Trigger: Calling providersAdapter.copyProviderConfig(type, configName, newConfigName) with a source configName not in the list, or a newConfigName that duplicates an existing config, or an unknown uploader type.

Common situations: User copies a config twice and the second attempt collides on the duplicate name; renaming elsewhere between listing and copying; leading/trailing whitespace making names appear unique but collide or miss.

Related errors


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