{"record":{"id":"4b5b6120857c67bc","repo":"alibaba/spring-ai-alibaba","slug":"name","errorCode":null,"errorMessage":"智能体名称已存在，请使用其他名称: ${name}","messagePattern":"智能体名称已存在，请使用其他名称: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"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/AgentSchemaServiceImpl.java","lineNumber":61,"sourceCode":"\t\timplements AgentSchemaService {\n\n\t@Override\n\tpublic AgentSchemaEntity createAgentSchema(AgentSchemaEntity agentSchemaEntity) {\n\t\tRequestContext requestContext = RequestContextHolder.getRequestContext();\n\n\t\t// Check for duplicate name in the same workspace\n\t\tString workspaceId = requestContext != null ? requestContext.getWorkspaceId() : null;\n\t\tif (StringUtils.isBlank(workspaceId)) {\n\t\t\tworkspaceId = \"1\"; // Use default workspace ID that matches database\n\t\t}\n\n\t\tLambdaQueryWrapper<AgentSchemaEntity> duplicateCheck = new LambdaQueryWrapper<>();\n\t\tduplicateCheck.eq(AgentSchemaEntity::getWorkspaceId, workspaceId);\n\t\tduplicateCheck.eq(AgentSchemaEntity::getName, agentSchemaEntity.getName());\n\t\tList<AgentSchemaEntity> existingAgents = list(duplicateCheck);\n\n\t\tif (!existingAgents.isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"智能体名称已存在，请使用其他名称: \" + agentSchemaEntity.getName());\n\t\t}\n\n\t\t// Set default values\n\t\tif (StringUtils.isBlank(agentSchemaEntity.getAgentId())) {\n\t\t\tagentSchemaEntity.setAgentId(IdGenerator.generateAgentId());\n\t\t}\n\n\t\tagentSchemaEntity.setWorkspaceId(workspaceId);\n\t\tagentSchemaEntity.setStatus(AgentStatus.ACTIVE);\n\t\tagentSchemaEntity.setEnabled(true);\n\t\tagentSchemaEntity.setGmtCreate(new Date());\n\t\tagentSchemaEntity.setGmtModified(new Date());\n\n\t\tString accountId = requestContext != null ? requestContext.getAccountId() : \"10000\";\n\t\tagentSchemaEntity.setCreator(accountId);\n\t\tagentSchemaEntity.setModifier(accountId);\n\n\t\tsave(agentSchemaEntity);","sourceCodeStart":43,"sourceCodeEnd":79,"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/AgentSchemaServiceImpl.java#L43-L79","documentation":"Business-rule rejection raised in AgentSchemaServiceImpl.createAgentSchema when an agent schema with the same name already exists in the target workspace. Before saving, the service queries the agent schema table filtered by workspaceId (defaulting to \"1\" when the request context carries no workspace) and the incoming name; a match means the name is not unique within that workspace, so creation is refused with a BizException rather than producing a duplicate. Callers should surface this to the user as a naming conflict and prompt for a different name.","triggerScenarios":"Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/AgentSchemaServiceImpl.java:61 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a different agent name within the workspace","Rename or delete the existing agent first","Include workspaceId in the uniqueness check on the client side before submit"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}