{"record":{"id":"f8ac9618abb246b4","repo":"iflytek/astron-agent","slug":"dataset-group-name-does-not-exist-in-ragflow","errorCode":null,"errorMessage":"Dataset '{group_name}' does not exist in RAGFlow","messagePattern":"Dataset '(.+?)' does not exist in RAGFlow","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/knowledge/infra/ragflow/ragflow_client.py","lineNumber":540,"sourceCode":"                \"refusing to silently fall back to RAGFLOW_DEFAULT_GROUP \"\n                \"to avoid cross-repo upload contamination\"\n            )\n        return sdk_datasets[0].upload_documents(\n            [{\"displayed_name\": filename, \"blob\": file_content}]\n        )\n\n    return await _upload_via_default_group(file_content=file_content, filename=filename)\n\n\nasync def _resolve_dataset_via_rest(group_name: str, rag: Any) -> Any:\n    \"\"\"Fallback: locate default-group dataset via REST when SDK name lookup fails.\n\n    Kept separate to avoid increasing default-group path complexity.\n    \"\"\"\n    rest_response = await list_datasets(name=group_name)\n    datasets = rest_response.get(\"data\", []) if rest_response else []\n    if not datasets:\n        raise ValueError(f\"Dataset '{group_name}' does not exist in RAGFlow\")\n    actual_id = datasets[0].get(\"id\")\n    if not actual_id:\n        raise ValueError(f\"Dataset '{group_name}' REST response missing id field\")\n    sdk_datasets: List[Any] = rag.list_datasets(id=actual_id)\n    if not sdk_datasets:\n        raise ValueError(\n            f\"Dataset '{group_name}' (id={actual_id}) not visible to ragflow_sdk\"\n        )\n    return sdk_datasets[0]\n\n\nasync def _upload_via_default_group(file_content: bytes, filename: str) -> List[Any]:\n    \"\"\"Legacy upload path using configured ``RAGFLOW_DEFAULT_GROUP``.\n\n    Kept separate to avoid increasing ``upload_document_to_dataset`` complexity.\n    \"\"\"\n    group_name = _config_value(\"default_group\", \"RAGFLOW_DEFAULT_GROUP\", \"\")\n    if not group_name:","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/infra/ragflow/ragflow_client.py#L522-L558","documentation":"Raised by _resolve_dataset_via_rest when a REST list_datasets call filtered by name returns no matching datasets. The upload path requires an existing RAGFlow dataset (knowledge base) with the configured group name; it refuses to create one implicitly.","triggerScenarios":"Calling upload_document_to_dataset without a dataset_id while RAGFLOW_DEFAULT_GROUP names a dataset that was deleted, renamed, or never created in RAGFlow; or the REST API returns an empty data[] because the API key belongs to a tenant that cannot see the dataset.","commonSituations":"Deploying to a fresh RAGFlow instance without provisioning the default knowledge base; typos in RAGFLOW_DEFAULT_GROUP; dataset deleted by an operator; mismatched RAGFlow API key/tenant between services.","solutions":["Create the dataset in RAGFlow with a name exactly matching the configured group_name (UI or POST /api/v1/datasets).","Verify RAGFLOW_DEFAULT_GROUP matches the dataset name exactly (case-sensitive, no stray whitespace).","Check that the RAGFlow API key used by the client belongs to the tenant that owns the dataset.","Call list_datasets via REST (GET /api/v1/datasets?name=...) with curl to confirm what the server returns."],"exampleFix":"# before (fail: dataset missing)\nexport RAGFLOW_DEFAULT_GROUP=knowledge-base\n# after (dataset created first in RAGFlow with exactly this name)\nexport RAGFLOW_DEFAULT_GROUP=knowledge-base\n# then: curl -X POST $RAGFLOW_BASE/api/v1/datasets -d '{\"name\":\"knowledge-base\"}'","handlingStrategy":"validation","validationCode":"async def dataset_exists(group_name: str) -> bool:\n    resp = await list_datasets(name=group_name)\n    return bool(resp and resp.get(\"data\"))\nif not await dataset_exists(RAGFLOW_DEFAULT_GROUP):\n    raise RuntimeError(f\"Provision dataset '{RAGFLOW_DEFAULT_GROUP}' before upload\")","typeGuard":null,"tryCatchPattern":"try:\n    doc = await upload_document_to_dataset(content, filename)\nexcept ValueError as e:\n    if \"does not exist in RAGFlow\" in str(e):\n        logger.error(f\"Dataset missing; create it or fix RAGFLOW_DEFAULT_GROUP: {e}\")\n    raise","preventionTips":["Provision the default dataset as part of deployment automation","Assert RAGFLOW_DEFAULT_GROUP names an existing dataset in a startup health check","Keep dataset names in one shared config constant to avoid typos"],"tags":["ragflow","dataset-not-found","configuration"],"backgroundTag":"resource-not-found","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"}