langgenius/dify · error · NotFound
not_found
not_found
Error message
Some documents not found: {list(missing_ids)} What it means
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.
Source
Thrown at api/controllers/console/datasets/datasets_document.py:1710
if dataset.indexing_technique != IndexTechniqueType.HIGH_QUALITY:
raise ValueError(
f"Summary generation is only available for 'high_quality' indexing technique. "
f"Current indexing technique: {dataset.indexing_technique}"
)
summary_index_setting = dataset.summary_index_setting
if not summary_index_setting or not summary_index_setting.get("enable"):
raise ValueError("Summary index is not enabled for this dataset. Please enable it in the dataset settings.")
# Verify all documents exist and belong to the dataset
documents = DocumentService.get_documents_by_ids(
DatasetRefService.create_dataset_ref(dataset), document_list, session
)
if len(documents) != len(document_list):
found_ids = {doc.id for doc in documents}
missing_ids = set(document_list) - found_ids
raise NotFound(f"Some documents not found: {list(missing_ids)}")
# Update need_summary to True for documents that don't have it set
# This handles the case where documents were created when summary_index_setting was disabled
documents_to_update = [doc for doc in documents if not doc.need_summary and doc.doc_form != "qa_model"]
if documents_to_update:
document_ids_to_update = [str(doc.id) for doc in documents_to_update]
DocumentService.update_documents_need_summary(
dataset_id=dataset_id_str,
document_ids=document_ids_to_update,
session=session,
need_summary=True,
)
# Dispatch async tasks for each document
for document in documents:
# Skip qa_model documents as they don't generate summaries
if document.doc_form == "qa_model":View on GitHub (pinned to ef8544b173)
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.
Example fix
# before
client.post(f'/datasets/{dataset_id}/generate-summary', json={'document_list': requested_ids})
# after
valid = {d['id'] for page in itertools.count(1) for d in client.get(f'/datasets/{dataset_id}/documents', params={'page': page}).json()['data']}
client.post(f'/datasets/{dataset_id}/generate-summary', json={'document_list': [i for i in requested_ids if i in valid]}) Defensive patterns
Strategy: validation
Validate before calling
existing = {d['id'] for d in client.get(f'/console/api/datasets/{dataset_id}/documents').json()['data']}
safe = [i for i in document_list if i in existing]
assert len(safe) == len(document_list), f'missing: {set(document_list) - existing}'
client.post(f'/datasets/{dataset_id}/generate-summary', json={'document_list': safe}) Type guard
def all_belong(ids: list[str], known: set[str]) -> bool:
return set(ids).issubset(known) Try / catch
try:
client.post(...)
except HTTPError as e:
if e.response.status_code == 404:
missing = e.response.json().get('missing_ids')
document_list = [i for i in document_list if i not in set(missing)] Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/0586497e7ed9a199.
Report an issue: GitHub.