{"record":{"id":"128554d8efdc0cef","repo":"run-llama/llama_index","slug":"query-and-response-must-be-provided-128554","errorCode":null,"errorMessage":"query, and response must be provided","messagePattern":"query, and response must be provided","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/evaluation/correctness.py","lineNumber":135,"sourceCode":"        if \"eval_template\" in prompts:\n            self._eval_template = prompts[\"eval_template\"]\n\n    async def aevaluate(\n        self,\n        query: Optional[str] = None,\n        response: Optional[str] = None,\n        contexts: Optional[Sequence[str]] = None,\n        reference: Optional[str] = None,\n        sleep_time_in_seconds: int = 0,\n        **kwargs: Any,\n    ) -> EvaluationResult:\n        del kwargs  # Unused\n        del contexts  # Unused\n\n        await asyncio.sleep(sleep_time_in_seconds)\n\n        if query is None or response is None:\n            raise ValueError(\"query, and response must be provided\")\n\n        eval_response = await self._llm.apredict(\n            prompt=self._eval_template,\n            query=query,\n            generated_answer=response,\n            reference_answer=reference or \"(NO REFERENCE ANSWER SUPPLIED)\",\n        )\n\n        # Use the parser function\n        score, reasoning = self.parser_function(eval_response)\n\n        return EvaluationResult(\n            query=query,\n            response=response,\n            passing=score >= self._score_threshold if score is not None else None,\n            score=score,\n            feedback=reasoning,\n        )","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/evaluation/correctness.py#L117-L153","documentation":"Thrown by CorrectnessEvaluator.aevaluate when query or response is None (contexts is discarded). The evaluator formats the eval prompt with query, generated_answer, and a reference_answer, so the query/response pair is mandatory; a missing reference degrades gracefully to a placeholder string instead.","triggerScenarios":"Calling await evaluator.aevaluate(query=None, response=r) or aevaluate(query=q, response=None); via BatchRunner when responses for some items are None (e.g. a query engine returned nothing) and are passed straight through.","commonSituations":"Evaluating retrieved question/answer pairs where one side is missing; response objects stringified to None because the engine errored or returned an empty completion; dataset rows with null fields.","solutions":["Ensure both query and response are non-None strings before calling aevaluate.","In batch pipelines, filter or placeholder-fill: skip items whose response is None, or substitute \"(NO RESPONSE)\" if you want a scored result.","Validate your QA dataset up front for null query/answer fields."],"exampleFix":"# before\nresult = await evaluator.aevaluate(query=q, response=resp)  # resp may be None\n\n# after\nif q is None or resp is None:\n    continue  # or skip/log this item\nresult = await evaluator.aevaluate(query=q, response=str(resp))","handlingStrategy":"validation","validationCode":"if not query or not response:\n    return None  # skip incomplete pair\nresult = await evaluator.aevaluate(query=query, response=str(response))","typeGuard":"def complete_qa_pair(q, r) -> bool:\n    return q is not None and r is not None","tryCatchPattern":null,"preventionTips":["Clean QA datasets up front: drop or fill rows with null question/answer fields.","Always str() the response before passing; never forward raw possibly-None objects."],"tags":["evaluation","correctness","input-validation"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}