{"record":{"id":"9963082a1e3e97d0","repo":"alibaba/spring-ai-alibaba","slug":"pluginnameexists","errorCode":"PluginNameExists","errorMessage":"Plugin name already exists.","messagePattern":"Plugin name already exists\\.","errorType":"error_code","errorClass":"BizException","httpStatus":400,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/PluginServiceImpl.java","lineNumber":93,"sourceCode":"\tpublic PluginServiceImpl(ToolMapper toolMapper, RedisManager redisManager) {\n\t\tthis.toolMapper = toolMapper;\n\t\tthis.redisManager = redisManager;\n\t}\n\n\t/**\n\t * Creates a new plugin\n\t * @param plugin Plugin information\n\t * @return Generated plugin ID\n\t */\n\t@Override\n\tpublic String createPlugin(Plugin plugin) {\n\t\ttry {\n\t\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\n\t\t\t// check if plugin name exists\n\t\t\tPluginEntity pluginEntity = getPluginByName(context.getWorkspaceId(), plugin.getName());\n\t\t\tif (pluginEntity != null) {\n\t\t\t\tthrow new BizException(ErrorCode.PLUGIN_NAME_EXISTS.toError());\n\t\t\t}\n\n\t\t\tString pluginId = IdGenerator.idStr();\n\t\t\tPluginEntity entity = BeanCopierUtils.copy(plugin, PluginEntity.class);\n\t\t\tentity.setPluginId(pluginId);\n\t\t\tentity.setWorkspaceId(context.getWorkspaceId());\n\n\t\t\tString config = JsonUtils.toJson(plugin.getConfig());\n\t\t\tentity.setConfig(config);\n\t\t\tentity.setType(PluginType.CUSTOM);\n\t\t\tentity.setStatus(PluginStatus.NORMAL);\n\n\t\t\tentity.setGmtCreate(new Date());\n\t\t\tentity.setGmtModified(new Date());\n\t\t\tentity.setCreator(context.getAccountId());\n\t\t\tentity.setModifier(context.getAccountId());\n\n\t\t\tthis.save(entity);","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/PluginServiceImpl.java#L75-L111","documentation":"Thrown by PluginServiceImpl.createPlugin when a plugin with the same name already exists in the current workspace. The service performs a name-uniqueness check (getPluginByName) before inserting and rejects duplicates.","triggerScenarios":"Calling createPlugin(plugin) with plugin.getName() matching an existing plugin in the same workspaceId.","commonSituations":"Retry of a create request that already succeeded; importing plugins from another workspace without renaming; UI/API allowing duplicate names under different casing.","solutions":["Rename the plugin to a unique name within the workspace","Query existing plugin names first and handle the conflict in the caller","Catch PluginNameExists BizException and surface a friendly conflict message"],"exampleFix":"// before\nplugin.setName(\"weather\");\npluginService.createPlugin(plugin);\n// after\nString name = \"weather\";\nif (pluginService.getPluginByName(workspaceId, name) != null) {\n    name = name + \"-\" + UUID.randomUUID().toString().substring(0, 6);\n}\nplugin.setName(name);\npluginService.createPlugin(plugin);","handlingStrategy":"try-catch","validationCode":"if (pluginService.getPluginByName(workspaceId, plugin.getName()) != null) {\n    plugin.setName(plugin.getName() + \"-\" + System.currentTimeMillis());\n}","typeGuard":null,"tryCatchPattern":"try {\n    pluginService.createPlugin(plugin);\n} catch (BizException e) {\n    // name-conflict is user-fixable: return 409\n    throw new ResponseStatusException(HttpStatus.CONFLICT, \"Plugin name already exists\");\n}","preventionTips":["Check name uniqueness in the UI before submit","Use workspace-scoped unique naming conventions","Make create requests idempotent on retry","Never import plugins without renaming collisions"],"tags":["plugin","duplicate","conflict","workspace"],"backgroundTag":"file-already-exists","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}