infiniflow/ragflow · error · GroupValidationError

Template name '{name}' already exists. Please choose another

Error message

Template name '{name}' already exists. Please choose another name.

What it means

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.

Source

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

                        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:
                        new_id = cls._insert_child(
                            group_id,
                            tenant_id,
                            {
                                "name": name,
                                "description": (child or {}).get("description") or "",
                                "kind": kind,
                                "config": config,
                            },
                            index=index,
                        )
                        retained_ids.add(new_id)
                        continue

                    CompilationTemplate.update(
                        name=name,

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Choose a different name for the template.
  2. Delete or rename the pre-existing conflicting template in the group first.
  3. List the group's current template names before saving and pick one that is free.

Example fix

// before: rename template A to "General" while template B already named "General"
{"id": "A", "name": "General"}
// after
{"id": "A", "name": "General (2)"}
Defensive patterns

Strategy: validation

Validate before calling

taken = {t['name'] for t in fetch_group_templates(group_id)}
for t in payload['templates']:
    if str(t.get('name') or '').strip() in taken and not t.get('id'):
        raise ValueError(f"name '{t['name']}' already used in this group")

Prevention

When it happens

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

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

Related errors


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