iflytek/astron-agent · error · ValueError
Dataset ' ' does not exist in RAGFlow
Error message
Dataset '{group_name}' does not exist in RAGFlow What it means
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.
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.
Example fix
# before (fail: dataset missing)
export RAGFLOW_DEFAULT_GROUP=knowledge-base
# after (dataset created first in RAGFlow with exactly this name)
export RAGFLOW_DEFAULT_GROUP=knowledge-base
# then: curl -X POST $RAGFLOW_BASE/api/v1/datasets -d '{"name":"knowledge-base"}' Defensive patterns
Strategy: validation
Validate before calling
async def dataset_exists(group_name: str) -> bool:
resp = await list_datasets(name=group_name)
return bool(resp and resp.get("data"))
if not await dataset_exists(RAGFLOW_DEFAULT_GROUP):
raise RuntimeError(f"Provision dataset '{RAGFLOW_DEFAULT_GROUP}' before upload") Try / catch
try:
doc = await upload_document_to_dataset(content, filename)
except ValueError as e:
if "does not exist in RAGFlow" in str(e):
logger.error(f"Dataset missing; create it or fix RAGFLOW_DEFAULT_GROUP: {e}")
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- RAGFLOW_BASE_URL not configured in environment variables
- RAGFLOW_API_TOKEN not configured in environment variables
- RAGFLOW_DEFAULT_GROUP is not set; cannot upload without…
- ChunkSaveFailed
- ChunkUpdateFailed
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/f8ac9618abb246b4.
Report an issue: GitHub.
Appendix: source
Thrown at core/knowledge/infra/ragflow/ragflow_client.py:540
"refusing to silently fall back to RAGFLOW_DEFAULT_GROUP "
"to avoid cross-repo upload contamination"
)
return sdk_datasets[0].upload_documents(
[{"displayed_name": filename, "blob": file_content}]
)
return await _upload_via_default_group(file_content=file_content, filename=filename)
async def _resolve_dataset_via_rest(group_name: str, rag: Any) -> Any:
"""Fallback: locate default-group dataset via REST when SDK name lookup fails.
Kept separate to avoid increasing default-group path complexity.
"""
rest_response = await list_datasets(name=group_name)
datasets = rest_response.get("data", []) if rest_response else []
if not datasets:
raise ValueError(f"Dataset '{group_name}' does not exist in RAGFlow")
actual_id = datasets[0].get("id")
if not actual_id:
raise ValueError(f"Dataset '{group_name}' REST response missing id field")
sdk_datasets: List[Any] = rag.list_datasets(id=actual_id)
if not sdk_datasets:
raise ValueError(
f"Dataset '{group_name}' (id={actual_id}) not visible to ragflow_sdk"
)
return sdk_datasets[0]
async def _upload_via_default_group(file_content: bytes, filename: str) -> List[Any]:
"""Legacy upload path using configured ``RAGFLOW_DEFAULT_GROUP``.
Kept separate to avoid increasing ``upload_document_to_dataset`` complexity.
"""
group_name = _config_value("default_group", "RAGFLOW_DEFAULT_GROUP", "")
if not group_name:View on GitHub (pinned to 5e758547a8)