{"record":{"id":"67fdec256465da85","repo":"langgenius/dify","slug":"dataset-not-found-67fdec","errorCode":null,"errorMessage":"Dataset not found.","messagePattern":"Dataset not found\\.","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"api/controllers/console/datasets/datasets_segments.py","lineNumber":719,"sourceCode":"    @with_current_tenant_id\n    @rbac_permission_required(RBACResourceScope.DATASET, RBACPermission.DATASET_EDIT)\n    @with_session\n    @model_validate(ChildChunkCreatePayload)\n    def post(\n        self,\n        req_data: ChildChunkCreatePayload,\n        session: Session,\n        current_tenant_id: str,\n        current_user: Account,\n        dataset_id: UUID,\n        document_id: UUID,\n        segment_id: UUID,\n    ):\n        # check dataset\n        dataset_id_str = str(dataset_id)\n        dataset = DatasetService.get_dataset(dataset_id_str, session)\n        if not dataset:\n            raise NotFound(\"Dataset not found.\")\n        # check document\n        document_id_str = str(document_id)\n        document = DocumentService.get_document(dataset_id_str, document_id_str, session=session)\n        if not document:\n            raise NotFound(\"Document not found.\")\n        if not current_user.is_dataset_editor:\n            raise Forbidden()\n        try:\n            DatasetService.check_dataset_permission(dataset, current_user, session)\n        except services.errors.account.NoPermissionError as e:\n            raise Forbidden(str(e))\n        # check embedding model setting\n        if dataset.indexing_technique == IndexTechniqueType.HIGH_QUALITY:\n            try:\n                model_manager = ModelManager.for_tenant(tenant_id=current_tenant_id)\n                model_manager.get_model_instance(\n                    tenant_id=current_tenant_id,\n                    provider=dataset.embedding_model_provider,","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/datasets/datasets_segments.py#L701-L737","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nPOST /datasets/{wrong_dataset_id}/documents/{doc_id}/segments/{seg_id}/child_chunks\n// after\nGET /datasets -> find correct dataset_id\nPOST /datasets/{correct_dataset_id}/documents/{doc_id}/segments/{seg_id}/child_chunks","handlingStrategy":"validation","validationCode":"async function ensureDataset(datasetId) {\n  const r = await fetch(`/console/api/datasets/${datasetId}`);\n  if (!r.ok) throw new Error('dataset not found; refresh the dataset id');\n  return r.json();\n}","typeGuard":"const isValidDatasetId = (id) => typeof id === 'string' && /^[0-9a-fA-F-]{36}$/.test(id);","tryCatchPattern":"try {\n  await ensureDataset(datasetId);\n  await createChildChunk({datasetId, documentId, segmentId, content});\n} catch (e) {\n  if (e.status === 404) { /* refresh ids, do not auto-retry destructively */ throw e; }\n  throw e;\n}","preventionTips":["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."],"tags":["datasets","child-chunk","not-found","rest-api"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}