fix: QA index processor preview key error#34236
fix: QA index processor preview key error#34236cyphercodes wants to merge 1 commit intolanggenius:mainfrom
Conversation
The QAIndexProcessor.format_preview method was returning 'qa_preview' key but the parent IndexProcessor.format_preview expected 'preview' key, causing a KeyError when using QA blocks in knowledge base workflows. Changed the return key from 'qa_preview' to 'preview' to match the expected interface. Fixes langgenius#34144
mahdirajaee
left a comment
There was a problem hiding this comment.
Clean, minimal fix that addresses the root cause directly. The QA index processor was returning qa_preview while the base IndexProcessor.format_preview interface expects preview, so this KeyError would have occurred every time a user attempted to preview QA-indexed segments through the knowledge base workflow.
One concern worth considering: this is a public-facing API response key change. If any external consumers (plugins, third-party integrations, or the frontend) were already handling the qa_preview key as a fallback or special case, changing it to preview could break those consumers in a different way. It would be worth verifying that the frontend chunk preview rendering code only reads from preview and never checks for qa_preview. That said, since the bug report indicates this was simply broken (KeyError), it is likely nobody was successfully consuming the old key anyway. The fix looks correct.
Summary
Fixed a KeyError that occurred when using QA blocks in knowledge base workflows.
Root Cause
The
QAIndexProcessor.format_previewmethod was returning a dictionary with the key'qa_preview', but the parentIndexProcessor.format_previewmethod expected the key'preview'. This caused aKeyError: 'preview'when iterating through the preview items.Changes
api/core/rag/index_processor/processor/qa_index_processor.py: Changed the return key from'qa_preview'to'preview'to match the expected interface.Testing
This fix ensures that QA blocks in knowledge base workflows can be previewed without errors.
Fixes #34144