infiniflow/ragflow · error · LookupError

Document({id}) not found.

Error message

Document({id}) not found.

What it means

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.

Source

Thrown at api/db/services/document_service.py:1036

            return []

        query = cls.model.select(cls.model.id).where(cls.model.name.in_(doc_names))
        return list(query.scalars().iterator())

    @classmethod
    @DB.connection_context()
    def get_thumbnails(cls, docids):
        fields = [cls.model.id, cls.model.kb_id, cls.model.thumbnail]
        return list(cls.model.select(*fields).where(cls.model.id.in_(docids)).dicts())

    @classmethod
    @DB.connection_context()
    def update_parser_config(cls, id, config):
        if not config:
            return
        e, d = cls.get_by_id(id)
        if not e:
            raise LookupError(f"Document({id}) not found.")

        def dfs_update(old, new):
            for k, v in new.items():
                if k not in old:
                    old[k] = v
                    continue
                if isinstance(v, dict) and isinstance(old[k], dict):
                    dfs_update(old[k], v)
                else:
                    old[k] = v

        dfs_update(d.parser_config, config)
        if not config.get("raptor") and d.parser_config.get("raptor"):
            del d.parser_config["raptor"]
        cls.update_by_id(id, {"parser_config": d.parser_config})

    @classmethod
    @DB.connection_context()

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Refetch the document list to get current ids before saving parser config.
  2. Confirm you are passing the Document id, not the file or dataset id.
  3. If the document was deleted, re-upload it instead of updating it.

Example fix

# before
DocumentService.update_parser_config(stale_doc_id, {"chunk_token_num": 512})
# after
ok, d = DocumentService.get_by_id(doc_id)
if not ok:
    raise LookupError(f"document {doc_id} gone; refetch list")
DocumentService.update_parser_config(d.id, {"chunk_token_num": 512})
Defensive patterns

Strategy: validation

Validate before calling

ok, existing = DocumentService.get_by_id(doc_id)
if not ok:
    raise LookupError(f'document {doc_id} not found — refetch the document list')
DocumentService.update_parser_config(doc_id, config)

Try / catch

try:
    DocumentService.update_parser_config(doc_id, config)
except LookupError:
    docs = refetch_documents(kb_id)  # reconcile client state, then apply to the fresh id

Prevention

When it happens

Trigger: Calling update_parser_config with an id that is deleted, wrong, or belongs to another tenant/scope where the lookup returns no row.

Common situations: 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.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/6c0b91d78bc2fc81. Report an issue: GitHub.