Description of the Bug
The list comprehension used to prepare query-document pairs (pairs = [(query, doc[text_key]) for doc in documents]) assumes that every dictionary passed inside the documents list contains the target text_key. If an unvalidated or poorly structured payload passes through, the code throws an unhandled KeyError and crashes the entire pipeline request.
Steps to Reproduce
Missing the default "text" key entirely
malformed_docs = [{"source": "system_logs"}]
reranker.rerank("query", malformed_docs)
Expected Behavior
The code should handle missing keys gracefully, either by skipping the invalid dictionary, logging a warning, or using a safe fallback like doc.get(text_key, "") to prevent the application from crashing.
Screenshots / Logs
No response
Environment
=
GSSoC '26
Description of the Bug
The list comprehension used to prepare query-document pairs (pairs = [(query, doc[text_key]) for doc in documents]) assumes that every dictionary passed inside the documents list contains the target text_key. If an unvalidated or poorly structured payload passes through, the code throws an unhandled KeyError and crashes the entire pipeline request.
Steps to Reproduce
Missing the default "text" key entirely
malformed_docs = [{"source": "system_logs"}]
reranker.rerank("query", malformed_docs)
Expected Behavior
The code should handle missing keys gracefully, either by skipping the invalid dictionary, logging a warning, or using a safe fallback like doc.get(text_key, "") to prevent the application from crashing.
Screenshots / Logs
No response
Environment
=
GSSoC '26