{"record":{"id":"269bf6d9879701d6","repo":"infiniflow/ragflow","slug":"dataset-nm-or-id-does-not-exist","errorCode":null,"errorMessage":"Dataset({nm_or_id}) does not exist.","messagePattern":"Dataset\\((.+?)\\) does not exist\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"agent/tools/retrieval.py","lineNumber":104,"sourceCode":"    def _dataset_ids(self):\n        \"\"\"Get dataset IDs with backward compatibility for kb_ids.\"\"\"\n        return self._param.dataset_ids or getattr(self._param, \"kb_ids\", None) or []\n\n    async def _retrieve_kb(self, query_text: str):\n        kb_ids: list[str] = []\n        for id in self._dataset_ids:\n            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","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/tools/retrieval.py#L86-L122","documentation":"The Retrieval agent component resolves dataset_ids entries containing '@' by reading a canvas variable and looking up each name-or-ID first via KnowledgebaseService.get_by_name(tenant) then get_by_id. If both lookups fail for any entry, it raises Exception('Dataset({nm_or_id}) does not exist.') (agent/tools/retrieval.py:104). The failing value is included in the message.","triggerScenarios":"A Retrieval component's dataset_ids references a canvas variable (e.g. 'begin@user.selected_kb') whose value is a deleted or misspelled dataset name/ID; the variable resolves to None or an arbitrary string that is neither an existing name nor a valid ID; the dataset belongs to a different tenant so get_by_name fails and the ID does not exist either.","commonSituations":"Dataset was deleted or renamed after the agent template was authored; the upstream component feeding the variable outputs free text instead of a real dataset identifier; importing an agent JSON from another tenant/environment whose dataset IDs do not exist locally.","solutions":["Open the dataset list in the UI, copy the exact current name or ID, and rebind the Retrieval component (or the variable feeding it).","If the value comes from a canvas variable, run the canvas with logging and confirm what the variable actually resolves to at runtime.","Verify the dataset belongs to the same tenant as the agent - get_by_name is scoped to self._canvas._tenant_id.","If you imported the agent from elsewhere, recreate the missing dataset or point the component at an existing one."],"exampleFix":"// before: canvas variable resolves to a stale name\n\"dataset_ids\": [\"begin@kb_name\"]  // kb_name was renamed\n\n// after\n\"dataset_ids\": [\"begin@my_dataset_current_name\"]","handlingStrategy":"validation","validationCode":"from api.db.services.knowledgebase_service import KnowledgebaseService\n\ndef resolve_dataset(nm_or_id, tenant_id):\n    e, kb = KnowledgebaseService.get_by_name(nm_or_id, tenant_id)\n    if not e:\n        e, kb = KnowledgebaseService.get_by_id(nm_or_id)\n    return kb if e else None\n\n# before running the canvas:\nfor entry in dataset_ids:\n    if '@' in entry:\n        for nm in as_list(canvas.get_variable_value(entry)):\n            assert resolve_dataset(nm, tenant_id) is not None, f\"unknown dataset {nm}\"","typeGuard":null,"tryCatchPattern":"try:\n    retrieval.invoke()\nexcept Exception as e:\n    if \"does not exist\" in str(e):\n        # surface to user: dataset binding is stale, prompt re-selection\n        raise UserFacingError(\"Please re-select the datasets for this agent\") from e\n    raise","preventionTips":["Rebind dataset references after renaming or deleting datasets.","Log resolved canvas-variable values at DEBUG so stale names are obvious.","When importing agents across environments, re-map all dataset name/ID references before running.","Prefer dataset IDs over names - names change more often."],"tags":["agent","retrieval","dataset","configuration","canvas"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}