iflytek/astron-agent · error · ValueError

group is required when ragType is not Ragflow-RAG

Error message

group is required when ragType is not Ragflow-RAG

What it means

ValueError raised by _require_group_for_non_ragflow: every RAG type except Ragflow-RAG (e.g. SparkDesk-RAG) mandates a non-empty group identifier, because those backends route retrieval by group. Ragflow-RAG is the only type that may omit it.

Solutions

  1. Provide the group field (the knowledge-base group ID issued for that RAG backend) whenever ragType != Ragflow-RAG.
  2. If Ragflow is actually intended, explicitly set ragType='Ragflow-RAG' so group becomes optional.
  3. Fix the frontend to show/require the group input for SparkDesk-RAG and other backends.
  4. Check the DTO mapping to ensure group isn't dropped or defaulted to None during request construction.

Example fix

// before
req = FileSplitReq(rag_type=RAGType.SparkDesk_RAG)  # group omitted -> ValueError
// after
req = FileSplitReq(rag_type=RAGType.SparkDesk_RAG, group="my-spark-group")
# or, if no group is truly needed:
req = FileSplitReq(rag_type=RAGType.RagFlow_RAG)
Defensive patterns

Strategy: validation

Validate before calling

def can_build_chunk_req(rag_type: str, group):
    return bool(group) or rag_type == "Ragflow-RAG"
# refuse to send the request until can_build_chunk_req(rag_type, group) is True

Type guard

def group_valid(rag_type: RAGType, group: Optional[str]) -> bool:
    return rag_type == RAGType.RagFlow_RAG or bool(group and group.strip())

Try / catch

try:
    submit_chunk_request(dto)
except ValueError as e:
    if "group is required" in str(e):
        prompt_user_for_group()  # or fall back to Ragflow-RAG
    else:
        raise

Prevention

When it happens

Trigger: A request DTO (e.g. FileSplitReq or chunk request) is built with rag_type set to anything other than RAGType.RagFlow_RAG while group is None or empty string — the validation helper called from _group_required_for_non_ragflow rejects it.

Common situations: Frontend hides the group field when users pick a non-Ragflow RAG type; default ragType switched (e.g. to SparkDesk-RAG) without collecting group; API consumers copying Ragflow payloads to other backends; group lost in form-to-DTO mapping.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/57472ab8de8de6d3. Report an issue: GitHub.

Appendix: source

Thrown at core/knowledge/domain/entity/chunk_dto.py:40

_DATASET_ID_LIST_DESC = (
    "RAGFlow dataset.id values for Ragflow-RAG routing; "
    "None or empty uses the default dataset."
)


class RAGType(str, Enum):
    """Define RAG type enumeration"""

    AIUI_RAG2 = "AIUI-RAG2"
    CBG_RAG = "CBG-RAG"
    SparkDesk_RAG = "SparkDesk-RAG"
    RagFlow_RAG = "Ragflow-RAG"


def _require_group_for_non_ragflow(rag_type: RAGType, group: Optional[str]) -> None:
    if rag_type != RAGType.RagFlow_RAG and not group:
        raise ValueError("group is required when ragType is not Ragflow-RAG")


class FileSplitReq(BaseModel):
    """
    File splitting request model

    Attributes:
        file: File content or path, required
        resourceType: Resource type, 0-regular file, 1-URL webpage, default is 0
        ragType: RAG type
        lengthRange: Split length range, optional
        overlap: Overlap length, optional
        separator: Separator list, optional
        cutOff: Cutoff marker list, optional
        titleSplit: Whether to split by title, default is False
        documentId: Existing RAGFlow doc id for re-slice upsert, optional
        group: Knowledge base group used by non-Ragflow strategies, optional
        datasetId: RAGFlow dataset.id for direct routing, optional

View on GitHub (pinned to 5e758547a8)