{"record":{"id":"0586497e7ed9a199","repo":"langgenius/dify","slug":"not-found-058649","errorCode":"not_found","errorMessage":"Some documents not found: {list(missing_ids)}","messagePattern":"Some documents not found: (.+?)","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"api/controllers/console/datasets/datasets_document.py","lineNumber":1710,"sourceCode":"        if dataset.indexing_technique != IndexTechniqueType.HIGH_QUALITY:\n            raise ValueError(\n                f\"Summary generation is only available for 'high_quality' indexing technique. \"\n                f\"Current indexing technique: {dataset.indexing_technique}\"\n            )\n\n        summary_index_setting = dataset.summary_index_setting\n        if not summary_index_setting or not summary_index_setting.get(\"enable\"):\n            raise ValueError(\"Summary index is not enabled for this dataset. Please enable it in the dataset settings.\")\n\n        # Verify all documents exist and belong to the dataset\n        documents = DocumentService.get_documents_by_ids(\n            DatasetRefService.create_dataset_ref(dataset), document_list, session\n        )\n\n        if len(documents) != len(document_list):\n            found_ids = {doc.id for doc in documents}\n            missing_ids = set(document_list) - found_ids\n            raise NotFound(f\"Some documents not found: {list(missing_ids)}\")\n\n        # Update need_summary to True for documents that don't have it set\n        # This handles the case where documents were created when summary_index_setting was disabled\n        documents_to_update = [doc for doc in documents if not doc.need_summary and doc.doc_form != \"qa_model\"]\n\n        if documents_to_update:\n            document_ids_to_update = [str(doc.id) for doc in documents_to_update]\n            DocumentService.update_documents_need_summary(\n                dataset_id=dataset_id_str,\n                document_ids=document_ids_to_update,\n                session=session,\n                need_summary=True,\n            )\n\n        # Dispatch async tasks for each document\n        for document in documents:\n            # Skip qa_model documents as they don't generate summaries\n            if document.doc_form == \"qa_model\":","sourceCodeStart":1692,"sourceCodeEnd":1728,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/datasets/datasets_document.py#L1692-L1728","documentation":"NotFound raised at datasets_document.py:1710 when DocumentService.get_documents_by_ids returns fewer rows than the number of IDs submitted in document_list. The difference set (requested minus found) is computed and reported as missing_ids. This guards against generating summaries for documents that do not exist or do not belong to the dataset.","triggerScenarios":"POST generate-summary with a document_list containing IDs that are deleted, belong to a different dataset, or are malformed. The ref-based lookup (DatasetRefService.create_dataset_ref) scopes the query to the dataset, so cross-dataset IDs count as missing.","commonSituations":"Stale document IDs cached on the client after a document was deleted; copy-paste error mixing IDs from two datasets; race where a document is purged between the UI listing documents and the summary request; UUID typos.","solutions":["Intersect the requested document_list with the current document set returned by GET /datasets/{id}/documents before submitting.","Parse missing_ids from the 404 response and re-issue only the still-valid IDs.","Confirm each ID is a UUID that belongs to the same dataset_id used in the path."],"exampleFix":"# before\nclient.post(f'/datasets/{dataset_id}/generate-summary', json={'document_list': requested_ids})\n\n# after\nvalid = {d['id'] for page in itertools.count(1) for d in client.get(f'/datasets/{dataset_id}/documents', params={'page': page}).json()['data']}\nclient.post(f'/datasets/{dataset_id}/generate-summary', json={'document_list': [i for i in requested_ids if i in valid]})","handlingStrategy":"validation","validationCode":"existing = {d['id'] for d in client.get(f'/console/api/datasets/{dataset_id}/documents').json()['data']}\nsafe = [i for i in document_list if i in existing]\nassert len(safe) == len(document_list), f'missing: {set(document_list) - existing}'\nclient.post(f'/datasets/{dataset_id}/generate-summary', json={'document_list': safe})","typeGuard":"def all_belong(ids: list[str], known: set[str]) -> bool:\n    return set(ids).issubset(known)","tryCatchPattern":"try:\n    client.post(...)\nexcept HTTPError as e:\n    if e.response.status_code == 404:\n        missing = e.response.json().get('missing_ids')\n        document_list = [i for i in document_list if i not in set(missing)]","preventionTips":["Always intersect requested IDs with the live document list before submitting.","Discard client-cached document IDs older than the last list fetch.","Log missing_ids to spot systematic staleness."],"tags":["datasets","summary-index","not-found","document-ownership","validation"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}