{"record":{"id":"75726d8492c2906d","repo":"infiniflow/ragflow","slug":"template-name-name-is-duplicated-in-this-group","errorCode":null,"errorMessage":"Template name '{name}' is duplicated in this group.","messagePattern":"Template name '(.+?)' is duplicated in this group\\.","errorType":"validation","errorClass":"GroupValidationError","httpStatus":null,"severity":"error","filePath":"api/db/services/compilation_template_group_service.py","lineNumber":327,"sourceCode":"                seen_names: set[str] = set()\n\n                for index, child in enumerate(templates):\n                    child_id = str((child or {}).get(\"id\") or \"\").strip()\n                    target = current_by_id.get(child_id) if child_id else None\n                    if child_id and target is None:\n                        raise GroupValidationError(f\"Template {child_id} does not belong to this group.\")\n                    # Older clients did not send child ids. Preserve their\n                    # existing ids by matching the submitted order.\n                    if target is None and not child_id and index < len(current_children):\n                        target = current_children[index]\n\n                    kind = str((child or {}).get(\"kind\") or \"\").strip()\n                    name = str((child or {}).get(\"name\") or \"\").strip()\n                    config = (child or {}).get(\"config\") or {}\n                    if not kind or not name or not isinstance(config, dict):\n                        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:","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/db/services/compilation_template_group_service.py#L309-L345","documentation":"GroupValidationError raised during group update when two or more submitted template entries in the same request share the same non-empty name. Uniqueness is tracked with a seen_names set across the submitted list, independent of the database check.","triggerScenarios":"Saving a group whose payload contains two templates with identical name strings (after strip). Happens before any DB duplicate query, so it fires even when the duplicates are new (unsaved) templates.","commonSituations":"Duplicating a template in the UI and forgetting to rename; default template name 'New template' auto-assigned twice; merging template lists that both contain a default-named entry.","solutions":["Rename one of the duplicated templates in the payload so all names are unique within the group.","Pre-validate client-side: check for duplicate names before submit.","If you cloned a template intentionally, give the clone a distinct name at creation time."],"exampleFix":"// before\n[{\"name\": \"Tree\"}, {\"name\": \"Tree\"}]\n// after\n[{\"name\": \"Tree\"}, {\"name\": \"Tree v2\"}]","handlingStrategy":"validation","validationCode":"names = [str(t.get('name') or '').strip() for t in payload['templates']]\nif len(names) != len(set(names)):\n    dupes = {n for n in names if names.count(n) > 1}\n    raise ValueError(f'duplicate template names in payload: {dupes}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Auto-suffix cloned templates ('name (copy)') in the UI.","Check name uniqueness against the whole group, not just the visible list."],"tags":["validation","duplicate-name","compilation-template"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}