{"record":{"id":"711ab2bda376e84e","repo":"iflytek/astron-agent","slug":"docids-is-not-empty","errorCode":null,"errorMessage":"docIds is not empty","messagePattern":"docIds is not empty","errorType":"validation","errorClass":"ProtocolParamException","httpStatus":null,"severity":"error","filePath":"core/knowledge/service/impl/cbg_strategy.py","lineNumber":66,"sourceCode":"        threshold: Optional[float] = 0,\n        **kwargs: Any\n    ) -> Dict[str, Any]:\n        \"\"\"\n        Execute RAG query\n\n        Args:\n            query: Query text\n            doc_ids: Document ID list\n            repo_ids: Knowledge base ID list\n            top_k: Number of results to return\n            threshold: Similarity threshold\n            **kwargs: Other parameters\n\n        Returns:\n            Query result dictionary\n        \"\"\"\n        if not check_not_empty(doc_ids):\n            raise ProtocolParamException(\"docIds is not empty\")\n\n        query_results = await xinghuo.new_topk_search(\n            query=query, doc_ids=doc_ids, top_n=top_k, **kwargs\n        )\n\n        results = []\n        if check_not_empty(query_results):\n            for result in query_results:\n                # Handle both string and dict results\n                if isinstance(result, str):\n                    try:\n                        result = json.loads(result)\n                    except json.JSONDecodeError:\n                        continue\n\n                processed_result = self._process_query_result(result, threshold or 0.0)\n                if processed_result:\n                    results.append(processed_result)","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/service/impl/cbg_strategy.py#L48-L84","documentation":"cbg_strategy.query requires document scoping: when doc_ids is empty, check_not_empty fails and ProtocolParamException('docIds is not empty') is raised before calling the Xinghuo retrieval backend. The RAG query must be constrained to at least one document.","triggerScenarios":"Calling query() with doc_ids=None, [] or other empty value — typically when the knowledge base has no indexed documents or the caller filtered out all doc ids before the call.","commonSituations":"Knowledge base not yet populated/uploaded to CBG; doc id list built by filtering deleted docs leaving zero entries; frontend sending an empty selection of documents.","solutions":["Ensure docIds contains at least one valid document id before calling query()","Check the knowledge base has documents uploaded/indexed in CBG; upload docs if empty","Guard the call site: return an empty result early when the doc id list is empty instead of invoking the strategy","Verify the doc id extraction/selection logic is not dropping valid ids"],"exampleFix":"// before\nresults = await strategy.query(query=q, doc_ids=doc_ids)\n// after\nif not doc_ids:\n    return []\nresults = await strategy.query(query=q, doc_ids=doc_ids)","handlingStrategy":"validation","validationCode":"if not doc_ids:\n    return {\"results\": []}  # short-circuit before calling the strategy","typeGuard":"def has_doc_ids(v) -> bool:\n    return isinstance(v, (list, tuple)) and len(v) > 0 and all(isinstance(i, str) and i for i in v)","tryCatchPattern":"try:\n    res = await strategy.query(query=q, doc_ids=doc_ids)\nexcept ProtocolParamException:\n    return {\"results\": []}","preventionTips":["Short-circuit queries when the document set is empty","Ensure documents are uploaded/indexed before enabling retrieval","Filter doc ids without dropping the list to empty silently","Unit-test query with empty/None doc id inputs"],"tags":["validation","parameter","rag"],"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-15T23:17:13.987Z"}