{"record":{"id":"26c76ab9123e7842","repo":"HKUDS/DeepTutor","slug":"select-at-most-one-pageindex-oss-knowledge-base-pe","errorCode":null,"errorMessage":"Select at most one PageIndex OSS knowledge base per request. Selected: {', '.join(selected)}","messagePattern":"Select at most one PageIndex OSS knowledge base per request\\. Selected: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/rag/pipelines/pageindex/__init__.py","lineNumber":41,"sourceCode":"        return None\n\n\ndef is_pageindex_kb(kb_name: str | None) -> bool:\n    from deeptutor.services.rag.factory import PAGEINDEX_OSS_PROVIDER, PAGEINDEX_PROVIDER\n\n    return _bound_pageindex_provider(kb_name) in {PAGEINDEX_PROVIDER, PAGEINDEX_OSS_PROVIDER}\n\n\ndef validate_pageindex_oss_selection(knowledge_bases: list[str]) -> None:\n    from deeptutor.services.rag.factory import PAGEINDEX_OSS_PROVIDER\n\n    selected = [\n        name\n        for name in dict.fromkeys(str(item or \"\").strip() for item in knowledge_bases)\n        if name and _bound_pageindex_provider(name) == PAGEINDEX_OSS_PROVIDER\n    ]\n    if len(selected) > 1:\n        raise ValueError(\n            \"Select at most one PageIndex OSS knowledge base per request. \"\n            f\"Selected: {', '.join(selected)}\"\n        )\n\n\n__all__ = [\"PageIndexPipeline\", \"is_pageindex_kb\", \"validate_pageindex_oss_selection\"]\n","sourceCodeStart":23,"sourceCodeEnd":48,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/rag/pipelines/pageindex/__init__.py#L23-L48","documentation":"validate_pageindex_oss_selection enforces that at most one PageIndex OSS (self-hosted) knowledge base may participate in a single request, because the OSS SDK binding is a singleton per process. Passing two or more distinct OSS KB names raises ValueError listing the offenders.","triggerScenarios":"Calling PageIndex pipeline explore()/handle() with a knowledge_bases list containing two or more names that bind to the PageIndex OSS provider (deduplicated, non-empty).","commonSituations":"Users selecting multiple OSS KBs in the UI multi-select, or API clients concatenating KB lists from different sources; cloud PageIndex KBs coexist fine, so the error fires only on multiple OSS entries.","solutions":["Remove all but one PageIndex OSS KB from the request; merge their documents into a single OSS KB if both corpora are needed.","If you need multiple corpora, use cloud PageIndex KBs alongside the single OSS one, or duplicate queries per OSS KB sequentially."],"exampleFix":"# before\nawait pipeline.explore(query=q, knowledge_bases=[\"oss-main\", \"oss-archive\"])\n\n# after\nawait pipeline.explore(query=q, knowledge_bases=[\"oss-main\", \"cloud-kb\"])","handlingStrategy":"validation","validationCode":"from deeptutor.services.rag.pipelines.pageindex import validate_pageindex_oss_selection\nvalidate_pageindex_oss_selection(knowledge_bases)  # raises before any network work","typeGuard":"def oss_kb_count(knowledge_bases: list[str]) -> int:\n    from deeptutor.services.rag.pipelines.pageindex import _bound_pageindex_provider, PAGEINDEX_OSS_PROVIDER\n    return sum(1 for n in dict.fromkeys(map(str, knowledge_bases)) if _bound_pageindex_provider(n) == PAGEINDEX_OSS_PROVIDER)","tryCatchPattern":"try:\n    validate_pageindex_oss_selection(kbs)\nexcept ValueError as e:\n    if \"at most one PageIndex OSS\" in str(e):\n        kbs = keep_single_oss_kb(kbs)  # dedupe to first OSS entry\n    else:\n        raise","preventionTips":["Limit UI multi-select to one OSS KB.","Call validate_pageindex_oss_selection at request assembly time.","Merge OSS corpora into one KB instead of stacking them."],"tags":["pageindex","knowledge-base","validation","rag"],"backgroundTag":"invalid-multi-select-configuration","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}