{"record":{"id":"bdad2d29b4407477","repo":"infiniflow/ragflow","slug":"a-compilation-template-named-name-already-exis","errorCode":null,"errorMessage":"A compilation template named '{name}' already exists. Please choose a different name.","messagePattern":"A compilation template named '(.+?)' already exists\\. Please choose a different name\\.","errorType":"validation","errorClass":"GroupValidationError","httpStatus":null,"severity":"error","filePath":"api/db/services/compilation_template_group_service.py","lineNumber":425,"sourceCode":"        index: int,\n    ) -> str:\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        from api.db.services.compilation_template_service import CompilationTemplateService\n\n        config = CompilationTemplateService.fill_config_default_llm(config, tenant_id)\n        duplicate = 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 duplicate.exists():\n            raise GroupValidationError(f\"A compilation template named '{name}' already exists. Please choose a different name.\")\n\n        template_id = get_uuid()\n        CompilationTemplate.create(\n            id=template_id,\n            tenant_id=tenant_id,\n            group_id=group_id,\n            name=name,\n            description=str((child or {}).get(\"description\") or \"\"),\n            kind=kind,\n            config=config,\n            is_builtin=False,\n            status=StatusEnum.VALID.value,\n        )\n        return template_id\n\n    @classmethod\n    def _purge_stale_invalid_children(cls, tenant_id: str, names: list[str]) -> None:\n        cleaned_names = [name for name in {str(name).strip() for name in names} if name]","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/db/services/compilation_template_group_service.py#L407-L443","documentation":"GroupValidationError from _insert_child when a VALID non-builtin template with the same name already exists in the same tenant and group. Functionally the DB duplicate check of error 444, but on the pure insert path (creating a brand-new child row).","triggerScenarios":"Calling the add-child/insert path with a name that already exists among the group's VALID non-builtin templates.","commonSituations":"Re-adding a template after a partially failed save left the row committed; retrying an insert whose first attempt succeeded server-side but failed client-side; scripted seeding run twice.","solutions":["Pick a unique name for the new template.","Before insert, query the group's templates and use a name that is free.","If the row exists from a previous partial save, update it instead of inserting a duplicate."],"exampleFix":"// before\nname = \"Tree\"  # already exists in group\n// after\nexisting = {t.name for t in group_templates}\nname = \"Tree\" if \"Tree\" not in existing else \"Tree (new)\"","handlingStrategy":"validation","validationCode":"existing = {t['name'] for t in fetch_group_templates(group_id)}\nif name in existing:\n    name = uniquify(name, existing)  # e.g. append ' (2)', ' (3)'...","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make insert flows idempotent: check-then-insert keyed by name.","After a failed save, verify whether rows committed before retrying."],"tags":["validation","duplicate-name","compilation-template","insert"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}