{"record":{"id":"0b42b49581ee9a5a","repo":"iflytek/astron-agent","slug":"dataset-group-name-id-actual-id-not-visible-to-ragflow-sdk","errorCode":null,"errorMessage":"Dataset '{group_name}' (id={actual_id}) not visible to ragflow_sdk","messagePattern":"Dataset '(.+?)' \\(id=(.+?)\\) not visible to ragflow_sdk","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/knowledge/infra/ragflow/ragflow_client.py","lineNumber":546,"sourceCode":"\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:\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)","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/infra/ragflow/ragflow_client.py#L528-L564","documentation":"Raised after the REST API resolved the dataset id, but the ragflow_sdk list_datasets(id=...) call returned nothing. REST and SDK layers disagree: the SDK session cannot see the dataset the REST API reported.","triggerScenarios":"SDK initialized with a different API key/base URL than the REST client; dataset deleted between the REST and SDK calls; SDK version incompatible with the RAGFlow server (id filtering not honored); tenant/permission mismatch.","commonSituations":"Split configuration where RAGFLOW_API_BASE differs between SDK and REST settings; RAGFlow server upgraded while the pinned ragflow-sdk is stale; concurrent dataset deletion during upload.","solutions":["Verify the SDK and REST paths use the same API key and base URL configuration.","Run rag.list_datasets() without filters via SDK and confirm the dataset id appears in the results.","Align the ragflow-sdk package version with the RAGFlow server version.","Re-run the request; if transient, check for concurrent deletions or replication lag on the RAGFlow side."],"exampleFix":"# before: assume SDK honors id filter\nsdk_datasets = rag.list_datasets(id=actual_id)\n# after: diagnose disagreement\nsdk_datasets = rag.list_datasets(id=actual_id)\nif not sdk_datasets:\n    all_ids = [d.id for d in rag.list_datasets()]\n    logger.error(f\"SDK sees datasets {all_ids}; REST returned id={actual_id}\")","handlingStrategy":"retry","validationCode":"def same_creds() -> bool:\n    return (os.getenv(\"RAGFLOW_API_KEY\") == os.getenv(\"RAGFLOW_SDK_API_KEY\") and\n            os.getenv(\"RAGFLOW_API_BASE\") == os.getenv(\"RAGFLOW_SDK_BASE\"))","typeGuard":null,"tryCatchPattern":"try:\n    doc = await upload_document_to_dataset(content, filename)\nexcept ValueError as e:\n    if \"not visible to ragflow_sdk\" in str(e):\n        logger.error(\"REST/SDK dataset visibility mismatch — check SDK config/version\", e)\n    raise","preventionTips":["Use a single configuration object for both REST and SDK paths","Keep ragflow-sdk version aligned with the server via dependency pinning","Add an integration test resolving a dataset via both REST and SDK"],"tags":["ragflow","sdk","consistency"],"backgroundTag":"unexpected-response-shape","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"}