fix: detect ainsert signature instead of silently swallowing TypeError#251
fix: detect ainsert signature instead of silently swallowing TypeError#251peterCheng123321 wants to merge 1 commit intoHKUDS:mainfrom
Conversation
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>
|
Thanks for the fix. I checked this against the current LightRAG The fallback path only checks whether Could you please update the compatibility logic to filter all optional extension kwargs against the actual |
|
@peterCheng123321 Thanks for the quick turnaround on this. Closing in favor of #255, which has just merged into main. The complete fix for #244 lives there:
The signature-detection idea you proposed here ended up being the core mechanism in #255, so your direction was right. Really appreciate the contribution. |
Summary
Fixes #244.
insert_text_content_with_multimodal_contentinutils.pywas wrapping the entirelightrag.ainsert()call in a bareexcept Exceptionthat logged a hint and returned silently. When LightRAG'sainsertdoes not accept amultimodal_contentkeyword argument (i.e. the standard PyPI release rather than the RAGAnything branch), theTypeErrorwas swallowed — meaning:kv_store_doc_statusentry was writtenadelete_by_doc_idreturned 404Fix: use
inspect.signatureto check upfront whetherainsertacceptsmultimodal_content. If it does, call with the full argument set. If not, emit a visiblelogger.warningand fall back to text-only insertion so the document is still indexed anddoc_statusis correctly written. Real errors (network failures, LLM errors, etc.) now propagate instead of being silently dropped.Test plan
process_document_complete()against the standard PyPI LightRAG release — confirmkv_store_doc_statusis created andadelete_by_doc_idsucceedsainserterrors (e.g. bad API key) now surface as exceptions