infiniflow/ragflow · error · GroupValidationError

A wiki template cannot be combined with other templates in t

Error message

A wiki template cannot be combined with other templates in the same group.

What it means

GroupValidationError raised by _derive_scope when a group contains a wiki-kind template together with anything else (two wikis, or a wiki plus a file-scope template). A wiki template maps the group to dataset scope and must be the sole child; mixing kinds would make the scope ambiguous and is rejected before _enforce_single_rechunk_tree runs.

Source

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


class GroupValidationError(ValueError):
    pass


def _derive_scope(templates: list[dict]) -> str:
    """Derive the group's scope from its child templates.

    One artifacts child = dataset scope (and must be the only child).
    Otherwise file scope, with no artifacts allowed.
    """
    if not templates:
        raise GroupValidationError("A template group must contain at least one template.")
    kinds = [str((t or {}).get("kind") or "").strip() for t in templates]
    artifact_count = sum(1 for k in kinds if k == "wiki")
    if artifact_count > 0:
        if artifact_count != 1 or len(templates) != 1:
            raise GroupValidationError("A wiki template cannot be combined with other templates in the same group.")
        return SCOPE_DATASET

    _enforce_single_rechunk_tree(templates)
    return SCOPE_FILE


def _enforce_single_rechunk_tree(templates: list[dict]) -> None:
    """At most one tree-kind child in the group may enable re-chunking.

    Re-chunking soft-deletes the doc's original chunks via
    ``available_int=0`` and inserts merged replacements; running two
    such templates would race on the same source chunks and produce
    non-deterministic output. Per-tenant invariant is enforced
    server-side here and mirrored client-side in
    ``group-interface.ts``.
    """
    rechunk_trees = 0
    for t in templates:

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Put the wiki template in its own group (single child), and keep file-scope templates in separate groups.
  2. Enforce the constraint in the UI: selecting a wiki template disables all other selections.
  3. Validate server-side before save: reject if any(k=='wiki') and len(templates)!=1.
  4. Fix import/merge logic that concatenates template lists across groups.

Example fix

# before
group = {"templates": [wiki_template, file_template]}

# after
wiki_group = {"templates": [wiki_template]}
file_group = {"templates": [file_template]}
Defensive patterns

Strategy: validation

Validate before calling

kinds = [str((t or {}).get("kind") or "").strip() for t in templates]
if kinds.count("wiki") > 0 and len(templates) != 1:
    raise ValueError("A wiki template must be alone in its group")

Type guard

def group_scope_compliant(templates: list[dict]) -> bool:
    kinds = [str((t or {}).get("kind") or "").strip() for t in templates]
    return kinds.count("wiki") in (0,) or (kinds.count("wiki") == 1 and len(templates) == 1)

Try / catch

try:
    create_group(name, templates)
except GroupValidationError as e:
    if "wiki" in str(e):
        # split payload into a wiki-only group and a file-scope group
        ...

Prevention

When it happens

Trigger: Creating/updating a group whose templates array includes a kind=='wiki' entry plus any other entry; a UI bug that preselects a wiki template alongside file templates; imports merging a wiki group with a regular group.

Common situations: Users multi-selecting templates of mixed kinds in the group editor; default-selection state that includes a wiki template; API payloads assembled by concatenating existing groups.

Related errors


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