langgenius/dify · error · NotFound
Dataset not found.
Error message
Dataset not found.
What it means
Raised by the create-child-chunk POST handler when DatasetService.get_dataset returns None for the given dataset_id. The dataset was not found in the current tenant/session, so the controller aborts with NotFound (HTTP 404) before any further validation.
Source
Thrown at api/controllers/console/datasets/datasets_segments.py:719
@with_current_tenant_id
@rbac_permission_required(RBACResourceScope.DATASET, RBACPermission.DATASET_EDIT)
@with_session
@model_validate(ChildChunkCreatePayload)
def post(
self,
req_data: ChildChunkCreatePayload,
session: Session,
current_tenant_id: str,
current_user: Account,
dataset_id: UUID,
document_id: UUID,
segment_id: UUID,
):
# check dataset
dataset_id_str = str(dataset_id)
dataset = DatasetService.get_dataset(dataset_id_str, session)
if not dataset:
raise NotFound("Dataset not found.")
# check document
document_id_str = str(document_id)
document = DocumentService.get_document(dataset_id_str, document_id_str, session=session)
if not document:
raise NotFound("Document not found.")
if not current_user.is_dataset_editor:
raise Forbidden()
try:
DatasetService.check_dataset_permission(dataset, current_user, session)
except services.errors.account.NoPermissionError as e:
raise Forbidden(str(e))
# check embedding model setting
if dataset.indexing_technique == IndexTechniqueType.HIGH_QUALITY:
try:
model_manager = ModelManager.for_tenant(tenant_id=current_tenant_id)
model_manager.get_model_instance(
tenant_id=current_tenant_id,
provider=dataset.embedding_model_provider,View on GitHub (pinned to ef8544b173)
Solutions
- Verify the dataset_id is correct for the current tenant by listing datasets first.
- If the dataset was deleted, recreate or restore it and use the new id.
- Refresh the parent resources in the UI before opening the child-chunk editor to avoid stale ids.
Example fix
// before
POST /datasets/{wrong_dataset_id}/documents/{doc_id}/segments/{seg_id}/child_chunks
// after
GET /datasets -> find correct dataset_id
POST /datasets/{correct_dataset_id}/documents/{doc_id}/segments/{seg_id}/child_chunks Defensive patterns
Strategy: validation
Validate before calling
async function ensureDataset(datasetId) {
const r = await fetch(`/console/api/datasets/${datasetId}`);
if (!r.ok) throw new Error('dataset not found; refresh the dataset id');
return r.json();
} Type guard
const isValidDatasetId = (id) => typeof id === 'string' && /^[0-9a-fA-F-]{36}$/.test(id); Try / catch
try {
await ensureDataset(datasetId);
await createChildChunk({datasetId, documentId, segmentId, content});
} catch (e) {
if (e.status === 404) { /* refresh ids, do not auto-retry destructively */ throw e; }
throw e;
} Prevention
- Refresh the dataset list before performing child-chunk writes.
- Pass dataset_id straight from the dataset resource object, not from a stored URL.
- Stop writes when the dataset list no longer contains the id.
When it happens
Trigger: POST /console/api/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks with a dataset_id that does not exist, was deleted, or belongs to a different tenant.
Common situations: Wrong dataset_id copied from another workspace; dataset was archived or hard-deleted between page load and the request; URL was constructed from stale frontend state.
Related errors
- Document not found.
- UploadFile not found.
- The job does not exist.
- Child chunk not found.
- API template not found.
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/67fdec256465da85.
Report an issue: GitHub.