{"record":{"id":"5a8a341150975178","repo":"iflytek/astron-agent","slug":"when-repotype-2-match-docids-is-required-and-must-contain-at","errorCode":null,"errorMessage":"When repoType=2, match.docIds is required and must contain at least one item.","messagePattern":"When repoType=2, match\\.docIds is required and must contain at least one item\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/workflow/engine/nodes/agent/agent_node.py","lineNumber":111,"sourceCode":"\n    :param name: Knowledge base name\n    :param description: Knowledge base description\n    :param topK: Number of top results to retrieve\n    :param repoType: Repository type (default: CBG_RAG)\n    :param match: Matching configuration for repositories and documents\n    \"\"\"\n\n    name: str = Field(min_length=1, max_length=128)\n    description: str = Field(min_length=0, max_length=1024)\n    topK: int = Field(ge=1, le=5)\n    repoType: int = Field(..., ge=1, le=3)\n    match: Match\n\n    @model_validator(mode=\"after\")\n    def check_doc_ids_when_repo_type(self) -> \"Knowledge\":\n        if self.repoType == 2:\n            if self.match.docIds is None or len(self.match.docIds) == 0:\n                raise ValueError(\n                    \"When repoType=2, match.docIds is required and must contain at least one item.\"\n                )\n        return self\n\n\nclass Skill(BaseModel):\n    \"\"\"Skill metadata passed to agent runtime.\n\n    :param skillId: Skill file identifier\n    :param name: Skill display name\n    :param description: Short summary injected into system prompt\n    :param downloadUrl: Presigned URL for lazily reading full SKILL.md content\n    :param resources: Relative-path resource manifest for referenced files\n    \"\"\"\n\n    class Resource(BaseModel):\n        path: str = Field(min_length=1)\n        name: str = Field(default=\"\")","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/engine/nodes/agent/agent_node.py#L93-L129","documentation":"Pydantic model_validator on the Knowledge model of an agent node: when repoType is 2 (selected-documents mode), match.docIds must be a non-empty list. The model enforces this at parse/validation time, raising ValueError which Pydantic surfaces as a validation error before the node executes.","triggerScenarios":"Defining a Knowledge config in an agent node with repoType=2 but omitting match.docIds, sending an empty list [], or docIds being null — typically from a programmatically built or hand-edited workflow definition.","commonSituations":"Building agent node configs from code where doc selection state was not persisted; copying a knowledge config from repoType=1 (whole repo) and flipping repoType to 2 without adding docIds; UI saving an empty selection.","solutions":["Populate match.docIds with at least one document ID when repoType=2","Change repoType to 1 (or another mode) if whole-repository retrieval is intended and no specific docs are needed","Add an upstream check in the workflow builder/UI to require doc selection before saving repoType=2"],"exampleFix":"// before\n{\"repoType\": 2, \"match\": {\"docIds\": []}}\n// after\n{\"repoType\": 2, \"match\": {\"docIds\": [\"doc-123\"]}}","handlingStrategy":"validation","validationCode":"def knowledge_config_valid(k: dict) -> bool:\n    if k.get(\"repoType\") == 2:\n        ids = (k.get(\"match\") or {}).get(\"docIds\") or []\n        return len(ids) > 0\n    return True","typeGuard":null,"tryCatchPattern":"from pydantic import ValidationError\ntry:\n    knowledge = Knowledge.model_validate(cfg)\nexcept ValidationError as e:\n    notify_user(\"doc selection required when repoType=2\")\n    return","preventionTips":["Require document selection in the UI before allowing repoType=2","Validate knowledge configs at workflow-save time, not just execution time"],"tags":["pydantic","validation","knowledge","agent-node"],"backgroundTag":"empty-required-field","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}