iflytek/astron-agent · error · ProtocolParamException

docIds is not empty

Error message

docIds is not empty

What it means

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.

Solutions

  1. Ensure docIds contains at least one valid document id before calling query()
  2. Check the knowledge base has documents uploaded/indexed in CBG; upload docs if empty
  3. Guard the call site: return an empty result early when the doc id list is empty instead of invoking the strategy
  4. Verify the doc id extraction/selection logic is not dropping valid ids

Example fix

// before
results = await strategy.query(query=q, doc_ids=doc_ids)
// after
if not doc_ids:
    return []
results = await strategy.query(query=q, doc_ids=doc_ids)
Defensive patterns

Strategy: validation

Validate before calling

if not doc_ids:
    return {"results": []}  # short-circuit before calling the strategy

Type guard

def has_doc_ids(v) -> bool:
    return isinstance(v, (list, tuple)) and len(v) > 0 and all(isinstance(i, str) and i for i in v)

Try / catch

try:
    res = await strategy.query(query=q, doc_ids=doc_ids)
except ProtocolParamException:
    return {"results": []}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at core/knowledge/service/impl/cbg_strategy.py:66

        threshold: Optional[float] = 0,
        **kwargs: Any
    ) -> Dict[str, Any]:
        """
        Execute RAG query

        Args:
            query: Query text
            doc_ids: Document ID list
            repo_ids: Knowledge base ID list
            top_k: Number of results to return
            threshold: Similarity threshold
            **kwargs: Other parameters

        Returns:
            Query result dictionary
        """
        if not check_not_empty(doc_ids):
            raise ProtocolParamException("docIds is not empty")

        query_results = await xinghuo.new_topk_search(
            query=query, doc_ids=doc_ids, top_n=top_k, **kwargs
        )

        results = []
        if check_not_empty(query_results):
            for result in query_results:
                # Handle both string and dict results
                if isinstance(result, str):
                    try:
                        result = json.loads(result)
                    except json.JSONDecodeError:
                        continue

                processed_result = self._process_query_result(result, threshold or 0.0)
                if processed_result:
                    results.append(processed_result)

View on GitHub (pinned to 5e758547a8)