iflytek/astron-agent · error · ThirdPartyException

RAGFLOW_RAGError

RAGFLOW_RAGError

Error message

RAGFlow get_document_info doc={doc_id} dataset={dataset_id}: code={code} message={msg}

What it means

get_document_info raises ThirdPartyException with CodeEnum.RAGFLOW_RAGError when the RAGFlow API returns an unrecognized non-success code (not the data-error code that maps to None). It wraps the server code and message for diagnosis.

Solutions

  1. Read the wrapped code/message to identify the RAGFlow-side failure; check RAGFlow server logs for that request.
  2. Validate dataset_id/doc_id and that the API key's tenant owns the dataset.
  3. Handle ThirdPartyException at the polling layer so status polling degrades gracefully (retry/abort) instead of crashing the pipeline.
  4. Retry with backoff for transient server errors (5xx-class codes).

Example fix

// before
info = await client.get_document_info(ds, doc)  // throws on transient error
// after
try { info = await client.get_document_info(ds, doc); }
catch (e) {
  logger.warn("transient get_document_info failure, will retry", e);
  await sleep(backoff++);
}
Defensive patterns

Strategy: try-catch

Try / catch

try:
    info = await get_document_info(dataset_id, document_id)
except ThirdPartyException as e:
    logger.warning(f"RAGFlow document info unavailable: {e}")
    # degrade: mark status unknown and let polling retry
    info = None

Prevention

When it happens

Trigger: GET document info returns an unexpected error code: internal RAGFlow error, permission denied for the dataset, invalid dataset/document id combination the server rejects with a non-data-error code, or server-side outage.

Common situations: Parsing-status polling (_query_document_parsing_status) hitting a RAGFlow that is restarting or degraded; dataset ids from another tenant; API key revoked mid-operation.

Related errors


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

Appendix: source

Thrown at core/knowledge/infra/ragflow/ragflow_client.py:792

        logger.warning(f"empty doc_id for dataset={dataset_id}")
        return None
    response = await list_documents_in_dataset(
        dataset_id, doc_id=doc_id, page=1, page_size=1
    )
    code = response.get("code")
    if code == 0:
        data = response.get("data") or {}
        docs = data.get("docs") or []
        # page_size=1 + server-side exact-match filter => at most one doc;
        # the id re-check is defensive in case a future RAGFlow release
        # relaxes the filter to LIKE.
        if docs and docs[0].get("id") == doc_id:
            return docs[0]
        return None
    if code == _RAGFLOW_DATA_ERROR:
        return None
    msg = response.get("message", "Unknown error")
    raise ThirdPartyException(
        msg=(
            f"RAGFlow get_document_info doc={doc_id} dataset={dataset_id}: "
            f"code={code} message={msg}"
        ),
        e=CodeEnum.RAGFLOW_RAGError,
    )


async def delete_documents(dataset_id: str, document_ids: List[str]) -> Dict[str, Any]:
    """
    Delete documents API

    Args:
        dataset_id: Dataset ID
        document_ids: List of document IDs to delete

    Returns:
        Deletion response

View on GitHub (pinned to 5e758547a8)