{"record":{"id":"85f0be7b8e45d4f5","repo":"infiniflow/ragflow","slug":"no-dataset-is-selected","errorCode":null,"errorMessage":"No dataset is selected.","messagePattern":"No dataset is selected\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"agent/tools/retrieval.py","lineNumber":111,"sourceCode":"            if id.find(\"@\") < 0:\n                kb_ids.append(id)\n                continue\n            kb_nm = self._canvas.get_variable_value(id)\n            # if kb_nm is a list\n            kb_nm_list = kb_nm if isinstance(kb_nm, list) else [kb_nm]\n            for nm_or_id in kb_nm_list:\n                e, kb = KnowledgebaseService.get_by_name(nm_or_id, self._canvas._tenant_id)\n                if not e:\n                    e, kb = KnowledgebaseService.get_by_id(nm_or_id)\n                    if not e:\n                        raise Exception(f\"Dataset({nm_or_id}) does not exist.\")\n                kb_ids.append(kb.id)\n\n        filtered_kb_ids: list[str] = list(set([kb_id for kb_id in kb_ids if kb_id]))\n\n        kbs = KnowledgebaseService.get_by_ids(filtered_kb_ids)\n        if not kbs:\n            raise Exception(\"No dataset is selected.\")\n\n        embd_nms = list(set([kb.embd_id for kb in kbs]))\n        assert len(embd_nms) == 1, \"Knowledge bases use different embedding models.\"\n\n        embd_mdl = None\n        if embd_nms:\n            tenant_id = self._canvas.get_tenant_id()\n            embd_model_config = resolve_model_config(tenant_id, LLMType.EMBEDDING, embd_nms[0])\n            embd_mdl = LLMBundle(tenant_id, embd_model_config)\n\n        rerank_mdl = None\n        if self._param.rerank_id:\n            rerank_model_config = resolve_model_config(kbs[0].tenant_id, LLMType.RERANK, self._param.rerank_id)\n            rerank_mdl = LLMBundle(kbs[0].tenant_id, rerank_model_config)\n\n        vars = self.get_input_elements_from_text(query_text)\n        vars = {k: o[\"value\"] for k, o in vars.items()}\n        query = self.string_format(query_text, vars)","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/tools/retrieval.py#L93-L129","documentation":"After collecting kb_ids from plain IDs and canvas-variable lookups, the Retrieval component filters out falsy IDs and calls KnowledgebaseService.get_by_ids. If that returns nothing (agent/tools/retrieval.py:111), it raises Exception('No dataset is selected.'), meaning the resolved ID set is empty or none of the IDs correspond to existing rows.","triggerScenarios":"dataset_ids is an empty list; the canvas variable feeding dataset_ids resolves to an empty list, empty string, or None (whose .id access or filtering yields nothing); all resolved IDs are empty strings and get filtered out; every looked-up dataset was deleted between authoring and run.","commonSituations":"A template agent whose dataset binding was cleared; an upstream component (e.g. a Switch or LLM branch) outputs an empty selection; datasets deleted after the agent was configured.","solutions":["Bind at least one existing dataset in the Retrieval component's configuration before running the canvas.","If dataset_ids uses a variable, debug-run the canvas and confirm the variable produces a non-empty list of valid dataset names/IDs.","Add a guard branch upstream: skip or short-circuit the Retrieval node when the selection is empty instead of letting it raise.","Confirm the datasets still exist and are accessible to the agent's tenant."],"exampleFix":"// before\n\"dataset_ids\": []  // nothing bound\n\n// after\n\"dataset_ids\": [\"6a1f2e...dataset-id...\"]","handlingStrategy":"validation","validationCode":"resolved = [kb_id for kb_id in dataset_ids if kb_id]\n# for variable-based entries, resolve each '@' reference first\nif not resolved:\n    raise ValueError(\"Retrieval component has no dataset bound - select at least one\")","typeGuard":null,"tryCatchPattern":"try:\n    retrieval.invoke()\nexcept Exception as e:\n    if \"No dataset is selected\" in str(e):\n        skip_or_warn(\"retrieval skipped: empty dataset selection\")\n    else:\n        raise","preventionTips":["Treat an empty dataset selection as a config error at authoring time, not run time.","Add a pre-check node in the canvas that validates non-empty selection before Retrieval.","Guard upstream components so they never emit empty/None into the dataset variable."],"tags":["agent","retrieval","dataset","configuration","empty-state"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}