infiniflow/ragflow · error · Error
dataset_id (or kb_id/knowledge_id) is required for retrieval
Error message
dataset_id (or kb_id/knowledge_id) is required for retrievalTest
What it means
Thrown in web/src/services/knowledge-service.ts:151 by chunkService.retrievalTest when the params object contains none of dataset_id, kb_id, or knowledge_id. The service normalizes those legacy aliases into dataset_ids for the POST to api.retrievalTest; with no dataset identifier the request cannot be built, so it fails fast client-side before any network call.
Source
Thrown at web/src/services/knowledge-service.ts:151
payload.available ??
(payload.available_int === undefined
? undefined
: payload.available_int === 1),
image_base64: payload.image_base64,
});
const getAvailableParam = (available?: number) => {
if (available === undefined) {
return undefined;
}
return available === 1 ? 'true' : 'false';
};
const chunkService = {
retrievalTest: async (params: Record<string, any>) => {
const datasetId = params.dataset_id || params.kb_id || params.knowledge_id;
if (!datasetId) {
throw new Error(
'dataset_id (or kb_id/knowledge_id) is required for retrievalTest',
);
}
const datasetIds = Array.isArray(datasetId) ? datasetId : [datasetId];
const rest = { ...params };
delete rest.dataset_id;
delete rest.kb_id;
delete rest.knowledge_id;
return request.post(api.retrievalTest, {
data: { ...rest, dataset_ids: datasetIds },
});
},
chunkList: async (params: Record<string, any>) => {
const datasetId = getDatasetId(params);
const documentId = getDocumentId(params);
const response = await request.get(api.chunkList(datasetId, documentId), {
params: {
page: params.page,View on GitHub (pinned to 554fb1133a)
Solutions
- Pass dataset_id (the current canonical key) explicitly in the params object
- Make the UI require a dataset selection before the test button is enabled
- Type the params as { dataset_id: string; [k: string]: unknown } so TypeScript enforces the key
- Extend the alias check if callers still legitimately use kb_id/knowledge_id
Example fix
// before
await chunkService.retrievalTest({
question: query,
page: 1,
page_size: 10,
});
// after
await chunkService.retrievalTest({
dataset_id: selectedKnowledgeBaseId,
question: query,
page: 1,
page_size: 10,
}); Defensive patterns
Strategy: validation
Validate before calling
const hasDatasetId = (p: Record<string, any>) => Boolean(p.dataset_id || p.kb_id || p.knowledge_id);
Type guard
const isRetrievalParams = (
p: unknown,
): p is { dataset_id: string } & Record<string, unknown> =>
typeof p === 'object' && p !== null &&
typeof (p as any).dataset_id === 'string' && (p as any).dataset_id.length > 0; Prevention
- Type params as { dataset_id: string; ... } so the key is compiler-enforced
- Require a knowledge-base selection in the retrieval-test UI before enabling the button
When it happens
Trigger: Calling retrievalTest({question, ...}) and forgetting the dataset key; using a renamed key the normalizer does not know (e.g. datasetId camelCase); the form/dropdown value bound to dataset_id is undefined because no knowledge base was selected; data flowing from a context where kb_id was dropped during a refactor.
Common situations: Testing retrieval before selecting a dataset in the UI. Key drift across API versions (kb_id → dataset_id) leaving some callers on the old name that was removed from the alias list. Optional-chaining somewhere upstream producing undefined silently.
Related errors
- 101
- Cannot search across datasets where some have embedding mode
- Datasets use different embedding models: {[kb.embd_id for kb
- Invalid {label} format: {value!r}
- main() must be defined or exported.
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/27e18bde8b5e4c45.
Report an issue: GitHub.