{"record":{"id":"73dc09f6ba0c42f7","repo":"run-llama/llama_index","slug":"invalid-mode-self-mode","errorCode":null,"errorMessage":"Invalid mode: {self.mode}","messagePattern":"Invalid mode: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/postprocessor/node.py","lineNumber":203,"sourceCode":"        query_bundle: Optional[QueryBundle] = None,\n    ) -> List[NodeWithScore]:\n        \"\"\"Postprocess nodes.\"\"\"\n        all_nodes: Dict[str, NodeWithScore] = {}\n        for node in nodes:\n            all_nodes[node.node.node_id] = node\n            if self.mode == \"next\":\n                all_nodes.update(get_forward_nodes(node, self.num_nodes, self.docstore))\n            elif self.mode == \"previous\":\n                all_nodes.update(\n                    get_backward_nodes(node, self.num_nodes, self.docstore)\n                )\n            elif self.mode == \"both\":\n                all_nodes.update(get_forward_nodes(node, self.num_nodes, self.docstore))\n                all_nodes.update(\n                    get_backward_nodes(node, self.num_nodes, self.docstore)\n                )\n            else:\n                raise ValueError(f\"Invalid mode: {self.mode}\")\n\n        all_nodes_values: List[NodeWithScore] = list(all_nodes.values())\n        sorted_nodes: List[NodeWithScore] = []\n        for node in all_nodes_values:\n            # variable to check if cand node is inserted\n            node_inserted = False\n            for i, cand in enumerate(sorted_nodes):\n                node_id = node.node.node_id\n                # prepend to current candidate\n                prev_node_info = cand.node.prev_node\n                next_node_info = cand.node.next_node\n                if prev_node_info is not None and node_id == prev_node_info.node_id:\n                    node_inserted = True\n                    sorted_nodes.insert(i, node)\n                    break\n                # append to current candidate\n                elif next_node_info is not None and node_id == next_node_info.node_id:\n                    node_inserted = True","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/postprocessor/node.py#L185-L221","documentation":"Error \"Invalid mode: {self.mode}\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/postprocessor/node.py:203 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set self.mode to a supported value before postprocessing.","Use one of the documented modes for this node postprocessor."],"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"}