{"record":{"id":"568651c68966454b","repo":"Molunerfinn/PicGo","slug":"failed-to-copy-provider-config","errorCode":null,"errorMessage":"Failed to copy provider config","messagePattern":"Failed to copy provider config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/renderer/adapters/providers.ts","lineNumber":47,"sourceCode":"    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\n  },\n  async deleteProviderConfig (type: string, configName: string) {\n    const result = await invokeRPC<IUploaderConfigItem>(IRPCActionType.DELETE_PICBED_CONFIG, type, configName)\n    if (!result.success) {\n      throw new Error(result.error || 'Failed to delete provider config')\n    }\n\n    return result.data\n  },\n  async copyProviderConfig (type: string, configName: string, newConfigName: string) {\n    const result = await invokeRPC<IUploaderConfigItem>(IRPCActionType.COPY_UPLOADER_CONFIG, type, configName, newConfigName)\n    if (!result.success) {\n      throw new Error(result.error || 'Failed to copy provider config')\n    }\n\n    return result.data\n  },\n  async saveProviderConfig (type: string, configId: string, values: IStringKeyMap) {\n    const result = await invokeRPC<boolean>(IRPCActionType.UPDATE_UPLOADER_CONFIG, type, configId, values)\n    if (!result.success) {\n      throw new Error(result.error || 'Failed to save provider config')\n    }\n\n    if (result.data !== true) {\n      throw new Error('Failed to save provider config')\n    }\n  },\n  getProviderSchema (type: string): Promise<ProviderSchemaResult> {\n    return new Promise((resolve, reject) => {\n      const cleanup = ipc.once(GET_PICBED_CONFIG, (config: IPicGoPluginConfig[], name: string) => {\n        resolve({ config, name })","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/Molunerfinn/PicGo/blob/07ec7068a5512344da093d49a8408fa63ba3421e/src/renderer/adapters/providers.ts#L29-L65","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pick a newConfigName that does not already exist in the type's config list","Refresh the config list and verify the source configName still exists before copying","Trim/normalize the new name to avoid whitespace-only collisions","Inspect result.error for the main-process message (name exists / source not found)"],"exampleFix":"// before\nawait copyProviderConfig(type, src, newName)\n// after\nconst { configList } = await getProviderConfigList(type)\nif (!configList.some(c => c._configName === newName)) await copyProviderConfig(type, src, newName.trim())","handlingStrategy":"validation","validationCode":"const { configList } = await getProviderConfigList(type)\nif (!configList.some(c => c._configName === configName)) throw new Error('source config not found')\nif (configList.some(c => c._configName === newConfigName)) throw new Error('target name already exists')","typeGuard":"function canCopy(list: IUploaderConfigItem[], src: string, dest: string): boolean { return list.some(c => c._configName === src) && !list.some(c => c._configName === dest) }","tryCatchPattern":"try {\n  await copyProviderConfig(type, configName, newConfigName)\n} catch (e) {\n  showNotification((e as Error).message || $T('TIPS_COPY_CONFIG_FAILED'))\n  await refreshConfigList(type)\n}","preventionTips":["Auto-generate unique names (e.g. append '-copy', '-copy-2') instead of a fixed suffix","Trim and normalize names before comparing","Reject empty or duplicate names in the input form","Refresh the list before copy operations"],"tags":["ipc","rpc","config","duplicate-name"],"backgroundTag":"rpc-failed-result","analyzedSha":"07ec7068a5512344da093d49a8408fa63ba3421e","analyzedAt":"2026-08-30T01:45:22.289Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}