infiniflow/ragflow · error · Exception

Dataset({nm_or_id}) does not exist.

Error message

Dataset({nm_or_id}) does not exist.

What it means

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.

Source

Thrown at agent/tools/retrieval.py:104

    def _dataset_ids(self):
        """Get dataset IDs with backward compatibility for kb_ids."""
        return self._param.dataset_ids or getattr(self._param, "kb_ids", None) or []

    async def _retrieve_kb(self, query_text: str):
        kb_ids: list[str] = []
        for id in self._dataset_ids:
            if id.find("@") < 0:
                kb_ids.append(id)
                continue
            kb_nm = self._canvas.get_variable_value(id)
            # if kb_nm is a list
            kb_nm_list = kb_nm if isinstance(kb_nm, list) else [kb_nm]
            for nm_or_id in kb_nm_list:
                e, kb = KnowledgebaseService.get_by_name(nm_or_id, self._canvas._tenant_id)
                if not e:
                    e, kb = KnowledgebaseService.get_by_id(nm_or_id)
                    if not e:
                        raise Exception(f"Dataset({nm_or_id}) does not exist.")
                kb_ids.append(kb.id)

        filtered_kb_ids: list[str] = list(set([kb_id for kb_id in kb_ids if kb_id]))

        kbs = KnowledgebaseService.get_by_ids(filtered_kb_ids)
        if not kbs:
            raise Exception("No dataset is selected.")

        embd_nms = list(set([kb.embd_id for kb in kbs]))
        assert len(embd_nms) == 1, "Knowledge bases use different embedding models."

        embd_mdl = None
        if embd_nms:
            tenant_id = self._canvas.get_tenant_id()
            embd_model_config = resolve_model_config(tenant_id, LLMType.EMBEDDING, embd_nms[0])
            embd_mdl = LLMBundle(tenant_id, embd_model_config)

        rerank_mdl = None

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Open the dataset list in the UI, copy the exact current name or ID, and rebind the Retrieval component (or the variable feeding it).
  2. If the value comes from a canvas variable, run the canvas with logging and confirm what the variable actually resolves to at runtime.
  3. Verify the dataset belongs to the same tenant as the agent - get_by_name is scoped to self._canvas._tenant_id.
  4. If you imported the agent from elsewhere, recreate the missing dataset or point the component at an existing one.

Example fix

// before: canvas variable resolves to a stale name
"dataset_ids": ["begin@kb_name"]  // kb_name was renamed

// after
"dataset_ids": ["begin@my_dataset_current_name"]
Defensive patterns

Strategy: validation

Validate before calling

from api.db.services.knowledgebase_service import KnowledgebaseService

def resolve_dataset(nm_or_id, tenant_id):
    e, kb = KnowledgebaseService.get_by_name(nm_or_id, tenant_id)
    if not e:
        e, kb = KnowledgebaseService.get_by_id(nm_or_id)
    return kb if e else None

# before running the canvas:
for entry in dataset_ids:
    if '@' in entry:
        for nm in as_list(canvas.get_variable_value(entry)):
            assert resolve_dataset(nm, tenant_id) is not None, f"unknown dataset {nm}"

Try / catch

try:
    retrieval.invoke()
except Exception as e:
    if "does not exist" in str(e):
        # surface to user: dataset binding is stale, prompt re-selection
        raise UserFacingError("Please re-select the datasets for this agent") from e
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/269bf6d9879701d6. Report an issue: GitHub.