{"record":{"id":"0b8c88c09ed8a70a","repo":"iflytek/astron-agent","slug":"ragflow-default-group-is-not-set-cannot-upload-without","errorCode":null,"errorMessage":"RAGFLOW_DEFAULT_GROUP is not set; cannot upload without dataset_id","messagePattern":"RAGFLOW_DEFAULT_GROUP is not set; cannot upload without dataset_id","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/knowledge/infra/ragflow/ragflow_client.py","lineNumber":559,"sourceCode":"    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:\n        raise ValueError(\n            \"RAGFLOW_DEFAULT_GROUP is not set; cannot upload without dataset_id\"\n        )\n    rag = get_rag_object()\n\n    sdk_hit: List[Any] = rag.list_datasets(name=group_name)\n    if sdk_hit:\n        dataset_obj = sdk_hit[0]\n    else:\n        logger.warning(\n            \"Dataset '%s' not visible via SDK lookup, refreshing via REST API\",\n            group_name,\n        )\n        dataset_obj = await _resolve_dataset_via_rest(group_name, rag)\n\n    return dataset_obj.upload_documents(\n        [{\"displayed_name\": filename, \"blob\": file_content}]\n    )\n","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/infra/ragflow/ragflow_client.py#L541-L577","documentation":"Legacy upload path (_upload_via_default_group) raises this when neither an explicit dataset_id was supplied nor RAGFLOW_DEFAULT_GROUP is configured. Without one of these the client has no target dataset to upload into.","triggerScenarios":"Calling upload_document_to_dataset with dataset_id empty/None while the RAGFLOW_DEFAULT_GROUP environment variable is unset or empty string; config loader returning a blank default.","commonSituations":"Fresh deployments missing the env var; docker-compose files not passing RAGFLOW_DEFAULT_GROUP into the knowledge container; .env not loaded in the service runtime.","solutions":["Set RAGFLOW_DEFAULT_GROUP to the name of an existing RAGFlow dataset in the service environment.","Pass an explicit dataset_id to upload_document_to_dataset instead of relying on the default group.","Confirm the env var reaches the container (docker compose config / kubectl describe pod env).","Verify _config_value reads the correct config source and that .env files are loaded."],"exampleFix":"# before\n# RAGFLOW_DEFAULT_GROUP unset\n# after (docker-compose.yml)\nknowledge:\n  environment:\n    RAGFLOW_DEFAULT_GROUP: knowledge-base","handlingStrategy":"validation","validationCode":"group = os.getenv(\"RAGFLOW_DEFAULT_GROUP\", \"\")\nif not group.strip():\n    raise RuntimeError(\"Set RAGFLOW_DEFAULT_GROUP or pass dataset_id explicitly\")","typeGuard":null,"tryCatchPattern":"try:\n    doc = await upload_document_to_dataset(content, filename)\nexcept ValueError as e:\n    if \"RAGFLOW_DEFAULT_GROUP is not set\" in str(e):\n        logger.error(\"Missing upload target: set RAGFLOW_DEFAULT_GROUP or pass dataset_id\")\n    raise","preventionTips":["Declare RAGFLOW_DEFAULT_GROUP in .env.example and compose/k8s manifests","Fail fast at service startup if required RAGFlow config is absent","Prefer passing explicit dataset_id over relying on ambient default group"],"tags":["ragflow","configuration","missing-env-var"],"backgroundTag":"missing-env-var","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"}