infiniflow/ragflow · error · Exception

No dataset is selected.

Error message

No dataset is selected.

What it means

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.

Source

Thrown at agent/tools/retrieval.py:111

            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
        if self._param.rerank_id:
            rerank_model_config = resolve_model_config(kbs[0].tenant_id, LLMType.RERANK, self._param.rerank_id)
            rerank_mdl = LLMBundle(kbs[0].tenant_id, rerank_model_config)

        vars = self.get_input_elements_from_text(query_text)
        vars = {k: o["value"] for k, o in vars.items()}
        query = self.string_format(query_text, vars)

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Bind at least one existing dataset in the Retrieval component's configuration before running the canvas.
  2. If dataset_ids uses a variable, debug-run the canvas and confirm the variable produces a non-empty list of valid dataset names/IDs.
  3. Add a guard branch upstream: skip or short-circuit the Retrieval node when the selection is empty instead of letting it raise.
  4. Confirm the datasets still exist and are accessible to the agent's tenant.

Example fix

// before
"dataset_ids": []  // nothing bound

// after
"dataset_ids": ["6a1f2e...dataset-id..."]
Defensive patterns

Strategy: validation

Validate before calling

resolved = [kb_id for kb_id in dataset_ids if kb_id]
# for variable-based entries, resolve each '@' reference first
if not resolved:
    raise ValueError("Retrieval component has no dataset bound - select at least one")

Try / catch

try:
    retrieval.invoke()
except Exception as e:
    if "No dataset is selected" in str(e):
        skip_or_warn("retrieval skipped: empty dataset selection")
    else:
        raise

Prevention

When it happens

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

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

Related errors


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