fix: detect ainsert signature instead of silently swallowing TypeError by peterCheng123321 · Pull Request #251 · HKUDS/RAG-Anything · GitHub
Skip to content

fix: detect ainsert signature instead of silently swallowing TypeError#251

Open
peterCheng123321 wants to merge 1 commit intoHKUDS:mainfrom
peterCheng123321:fix/244-silent-ainsert-failure
Open

fix: detect ainsert signature instead of silently swallowing TypeError#251
peterCheng123321 wants to merge 1 commit intoHKUDS:mainfrom
peterCheng123321:fix/244-silent-ainsert-failure

Conversation

@peterCheng123321
Copy link
Copy Markdown

@peterCheng123321 peterCheng123321 commented Apr 21, 2026

Summary

Fixes #244.

insert_text_content_with_multimodal_content in utils.py was wrapping the entire lightrag.ainsert() call in a bare except Exception that logged a hint and returned silently. When LightRAG's ainsert does not accept a multimodal_content keyword argument (i.e. the standard PyPI release rather than the RAGAnything branch), the TypeError was swallowed — meaning:

  • No text was indexed
  • No kv_store_doc_status entry was written
  • adelete_by_doc_id returned 404

Fix: use inspect.signature to check upfront whether ainsert accepts multimodal_content. If it does, call with the full argument set. If not, emit a visible logger.warning and fall back to text-only insertion so the document is still indexed and doc_status is correctly written. Real errors (network failures, LLM errors, etc.) now propagate instead of being silently dropped.

Test plan

  • Run process_document_complete() against the standard PyPI LightRAG release — confirm kv_store_doc_status is created and adelete_by_doc_id succeeds
  • Run against the RAGAnything LightRAG branch — confirm full multimodal path still works
  • Confirm any real ainsert errors (e.g. bad API key) now surface as exceptions

insert_text_content_with_multimodal_content was catching all exceptions
and logging a hint, so a TypeError from an incompatible LightRAG version
(ainsert lacking multimodal_content) caused the entire insert to be
silently dropped — no text indexed, no doc_status written, and
adelete_by_doc_id returning 404.

Use inspect.signature to check upfront whether ainsert accepts
multimodal_content, and fall back to text-only insertion with a visible
warning if it does not. Real errors now propagate instead of being
swallowed.

Fixes HKUDS#244

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: No doc_status created after process_document_complete

2 participants