{"record":{"id":"736e5d365959a46b","repo":"run-llama/llama_index","slug":"expected-pydanticresponse-got-type-response","errorCode":null,"errorMessage":"Expected PydanticResponse, got {type(response)}","messagePattern":"Expected PydanticResponse, got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/node_parser/relational/base_element.py","lineNumber":232,"sourceCode":"                next_context = self._get_context_lines(\n                    str(elements[idx + 1].element), from_end=False, num_lines=3\n                )\n                if next_context:\n                    table_context += \"\\n\" + next_context\n\n            table_context_list.append(table_context)\n\n        async def _get_table_output(table_context: str, summary_query_str: str) -> Any:\n            index = SummaryIndex.from_documents(\n                [Document(text=table_context)],\n            )\n            query_engine = index.as_query_engine(llm=llm, output_cls=TableOutput)\n            try:\n                response = await query_engine.aquery(summary_query_str)\n                if isinstance(response, PydanticResponse):\n                    return response.response\n                else:\n                    raise ValueError(f\"Expected PydanticResponse, got {type(response)}\")\n            except (ValidationError, ValueError):\n                # There was a pydantic validation error, so we will run with text completion\n                # fill in the summary and leave other fields blank\n                query_engine = index.as_query_engine(llm=llm)\n                response_txt = await query_engine.aquery(summary_query_str)\n                return TableOutput(summary=str(response_txt), columns=[])\n\n        summary_jobs = [\n            _get_table_output(table_context, self.summary_query_str)\n            for table_context in table_context_list\n        ]\n        summary_co = run_jobs(summary_jobs, workers=self.num_workers)\n        summary_outputs = asyncio_run(summary_co)\n        # Only assign table_output to table elements (not all elements)\n        table_elements = [e for e in elements if e.type in (\"table\", \"table_text\")]\n        for element, summary_output in zip(table_elements, summary_outputs):\n            element.table_output = summary_output\n","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/node_parser/relational/base_element.py#L214-L250","documentation":"Error \"Expected PydanticResponse, got {type(response)}\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/node_parser/relational/base_element.py:232 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the LLM program returns a PydanticResponse for table extraction.","Check the output parser configuration of the element extraction program."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}