infiniflow/ragflow · error · GroupValidationError

Template name '{name}' is duplicated in this group.

Error message

Template name '{name}' is duplicated in this group.

What it means

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.

Source

Thrown at api/db/services/compilation_template_group_service.py:327

                seen_names: set[str] = set()

                for index, child in enumerate(templates):
                    child_id = str((child or {}).get("id") or "").strip()
                    target = current_by_id.get(child_id) if child_id else None
                    if child_id and target is None:
                        raise GroupValidationError(f"Template {child_id} does not belong to this group.")
                    # Older clients did not send child ids. Preserve their
                    # existing ids by matching the submitted order.
                    if target is None and not child_id and index < len(current_children):
                        target = current_children[index]

                    kind = str((child or {}).get("kind") or "").strip()
                    name = str((child or {}).get("name") or "").strip()
                    config = (child or {}).get("config") or {}
                    if not kind or not name or not isinstance(config, dict):
                        raise GroupValidationError("Each template must include a name, kind, and config object.")
                    if name in seen_names:
                        raise GroupValidationError(f"Template name '{name}' is duplicated in this group.")
                    seen_names.add(name)

                    from api.db.services.compilation_template_service import CompilationTemplateService

                    config = CompilationTemplateService.fill_config_default_llm(config, tenant_id)
                    duplicate_query = CompilationTemplate.select().where(
                        CompilationTemplate.tenant_id == tenant_id,
                        CompilationTemplate.group_id == group_id,
                        CompilationTemplate.name == name,
                        ~CompilationTemplate.is_builtin,
                        CompilationTemplate.status == StatusEnum.VALID.value,
                    )
                    if target is not None:
                        duplicate_query = duplicate_query.where(CompilationTemplate.id != target.id)
                    if duplicate_query.exists():
                        raise GroupValidationError(f"Template name '{name}' already exists. Please choose another name.")

                    if target is None:

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Rename one of the duplicated templates in the payload so all names are unique within the group.
  2. Pre-validate client-side: check for duplicate names before submit.
  3. If you cloned a template intentionally, give the clone a distinct name at creation time.

Example fix

// before
[{"name": "Tree"}, {"name": "Tree"}]
// after
[{"name": "Tree"}, {"name": "Tree v2"}]
Defensive patterns

Strategy: validation

Validate before calling

names = [str(t.get('name') or '').strip() for t in payload['templates']]
if len(names) != len(set(names)):
    dupes = {n for n in names if names.count(n) > 1}
    raise ValueError(f'duplicate template names in payload: {dupes}')

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/75726d8492c2906d. Report an issue: GitHub.