{"record":{"id":"6c0b91d78bc2fc81","repo":"infiniflow/ragflow","slug":"document-id-not-found","errorCode":null,"errorMessage":"Document({id}) not found.","messagePattern":"Document\\((.+?)\\) not found\\.","errorType":"exception","errorClass":"LookupError","httpStatus":null,"severity":"error","filePath":"api/db/services/document_service.py","lineNumber":1036,"sourceCode":"            return []\n\n        query = cls.model.select(cls.model.id).where(cls.model.name.in_(doc_names))\n        return list(query.scalars().iterator())\n\n    @classmethod\n    @DB.connection_context()\n    def get_thumbnails(cls, docids):\n        fields = [cls.model.id, cls.model.kb_id, cls.model.thumbnail]\n        return list(cls.model.select(*fields).where(cls.model.id.in_(docids)).dicts())\n\n    @classmethod\n    @DB.connection_context()\n    def update_parser_config(cls, id, config):\n        if not config:\n            return\n        e, d = cls.get_by_id(id)\n        if not e:\n            raise LookupError(f\"Document({id}) not found.\")\n\n        def dfs_update(old, new):\n            for k, v in new.items():\n                if k not in old:\n                    old[k] = v\n                    continue\n                if isinstance(v, dict) and isinstance(old[k], dict):\n                    dfs_update(old[k], v)\n                else:\n                    old[k] = v\n\n        dfs_update(d.parser_config, config)\n        if not config.get(\"raptor\") and d.parser_config.get(\"raptor\"):\n            del d.parser_config[\"raptor\"]\n        cls.update_by_id(id, {\"parser_config\": d.parser_config})\n\n    @classmethod\n    @DB.connection_context()","sourceCodeStart":1018,"sourceCodeEnd":1054,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/db/services/document_service.py#L1018-L1054","documentation":"LookupError from DocumentService.update_parser_config when get_by_id finds no Document row for the given id. The service refuses to merge parser config into a nonexistent document.","triggerScenarios":"Calling update_parser_config with an id that is deleted, wrong, or belongs to another tenant/scope where the lookup returns no row.","commonSituations":"Document removed in another session while its settings panel was open; stale id in client state after re-upload; passing kb_id or file_id where doc id is expected.","solutions":["Refetch the document list to get current ids before saving parser config.","Confirm you are passing the Document id, not the file or dataset id.","If the document was deleted, re-upload it instead of updating it."],"exampleFix":"# before\nDocumentService.update_parser_config(stale_doc_id, {\"chunk_token_num\": 512})\n# after\nok, d = DocumentService.get_by_id(doc_id)\nif not ok:\n    raise LookupError(f\"document {doc_id} gone; refetch list\")\nDocumentService.update_parser_config(d.id, {\"chunk_token_num\": 512})","handlingStrategy":"validation","validationCode":"ok, existing = DocumentService.get_by_id(doc_id)\nif not ok:\n    raise LookupError(f'document {doc_id} not found — refetch the document list')\nDocumentService.update_parser_config(doc_id, config)","typeGuard":null,"tryCatchPattern":"try:\n    DocumentService.update_parser_config(doc_id, config)\nexcept LookupError:\n    docs = refetch_documents(kb_id)  # reconcile client state, then apply to the fresh id","preventionTips":["Refetch document ids after deletions or re-uploads before saving settings.","Distinguish document id from file id and kb id in all call sites."],"tags":["lookup","document","parser-config","stale-id"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}