{"record":{"id":"9b92891b194b3466","repo":"infiniflow/ragflow","slug":"template-name-name-already-exists-please-choo","errorCode":null,"errorMessage":"Template name '{name}' already exists. Please choose another name.","messagePattern":"Template name '(.+?)' already exists\\. Please choose another name\\.","errorType":"validation","errorClass":"GroupValidationError","httpStatus":null,"severity":"error","filePath":"api/db/services/compilation_template_group_service.py","lineNumber":343,"sourceCode":"                        raise GroupValidationError(\"Each template must include a name, kind, and config object.\")\n                    if name in seen_names:\n                        raise GroupValidationError(f\"Template name '{name}' is duplicated in this group.\")\n                    seen_names.add(name)\n\n                    from api.db.services.compilation_template_service import CompilationTemplateService\n\n                    config = CompilationTemplateService.fill_config_default_llm(config, tenant_id)\n                    duplicate_query = CompilationTemplate.select().where(\n                        CompilationTemplate.tenant_id == tenant_id,\n                        CompilationTemplate.group_id == group_id,\n                        CompilationTemplate.name == name,\n                        ~CompilationTemplate.is_builtin,\n                        CompilationTemplate.status == StatusEnum.VALID.value,\n                    )\n                    if target is not None:\n                        duplicate_query = duplicate_query.where(CompilationTemplate.id != target.id)\n                    if duplicate_query.exists():\n                        raise GroupValidationError(f\"Template name '{name}' already exists. Please choose another name.\")\n\n                    if target is None:\n                        new_id = cls._insert_child(\n                            group_id,\n                            tenant_id,\n                            {\n                                \"name\": name,\n                                \"description\": (child or {}).get(\"description\") or \"\",\n                                \"kind\": kind,\n                                \"config\": config,\n                            },\n                            index=index,\n                        )\n                        retained_ids.add(new_id)\n                        continue\n\n                    CompilationTemplate.update(\n                        name=name,","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/db/services/compilation_template_group_service.py#L325-L361","documentation":"GroupValidationError raised during group update when a VALID, non-builtin template row already exists in the same tenant/group with the submitted name and a different id (the current target's id is excluded from the query). It is the database-level name-uniqueness check for user templates, complementing the in-request duplicate check.","triggerScenarios":"Group update that renames template A to a name already held by template B in the same group, where B is not the entry being updated (target is None or a different row).","commonSituations":"Renaming to a name that exists among hidden/soft templates that are still status==VALID; importing templates that collide with existing names; renaming after another user of the tenant created the same name.","solutions":["Choose a different name for the template.","Delete or rename the pre-existing conflicting template in the group first.","List the group's current template names before saving and pick one that is free."],"exampleFix":"// before: rename template A to \"General\" while template B already named \"General\"\n{\"id\": \"A\", \"name\": \"General\"}\n// after\n{\"id\": \"A\", \"name\": \"General (2)\"}","handlingStrategy":"validation","validationCode":"taken = {t['name'] for t in fetch_group_templates(group_id)}\nfor t in payload['templates']:\n    if str(t.get('name') or '').strip() in taken and not t.get('id'):\n        raise ValueError(f\"name '{t['name']}' already used in this group\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Debounce a name-availability check while the user types.","Remember the exclusion is id-based: renaming a template to its own current name is fine."],"tags":["validation","duplicate-name","database","compilation-template"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}